+ Reply to Thread
Results 1 to 11 of 11

automatically copy and paste values

  1. #1
    Registered User
    Join Date
    12-17-2008
    Location
    thailand
    MS-Off Ver
    2007
    Posts
    28

    automatically copy and paste values

    Hi there,

    I need to automatically copy cell IR18 value to cell JT18. I've been searching the forum for some code and I came up with something that only partially works for me:

    Please Login or Register  to view this content.
    This code works fine if I manually fill IR18, the problem is that IR18 contains an IF formula normally set to "", when IS18 is populated (which is populated when the array "calendar!I162:calendar!J171 is manually filled) IR18 returns a number but I get nothing on JT18, so I changed the above code to:

    Please Login or Register  to view this content.
    I don't have any code error but still it doesn't work. Any suggestions? Or a totally new code?

    Thank you in advance and merry xmas you all.
    Last edited by robbi100; 12-26-2008 at 11:23 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    You can not create your own events in that way.

    Worksheet_Change2 would be a module private the sheet but nothing would cause it to run unless explicitly called.

    Try something like this which checks all cells that are involved.
    Please Login or Register  to view this content.
    Any reason why JT18 can not reference IR18 via a formula?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    12-17-2008
    Location
    thailand
    MS-Off Ver
    2007
    Posts
    28
    What a quick response! I'm amazed.

    Any reason why JT18 can not reference IR18 via a formula?
    Column IR was meant to be the x values of a dynamic chart, the IF formula in it prevents numbers to be displayed still the chart recognize the "empty cells" containing formulas as not empty becoming very much static, that's why I need to copy IR18:IR39 array to JT18:JT39 leaving "future cells" completely empty, I tried to copy IR18:IR39 and paste only values on JT18:JT39 so that I;ve officially empty cells (nothing appear on the formula bar) but the chart still recognize them as not empty, I know because when I clear the contents of that "empty cells" the chart works, i thought that a macro would be the only way.

    about your code I don't have any errors but it doesn't work, maybe because the macro is in sheet2 while I162:J171 array is in sheet1 called "calendar", I tried to refer the array in your code to sheet1 but I'm really new to vba and couldn't get anything good.

    thank you very much for your time and efforts

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    You don't show your formula but a guess would be

    =IF( <test> , <Value> . "" )

    in which case the chart will treat the "" as text and text values are plotted as zero.

    If you alter your formula to

    =IF( <test> , <Value> . NA() )

    then in a line chart the data marker will not be displayed. The line itself will not be broken but it will only be plotted between valid data points.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    If the information in I162:J171 is on another sheet you will need to add code to that sheets event.

    Please Login or Register  to view this content.
    change sheet1 to whatever is appropriate.

  6. #6
    Registered User
    Join Date
    12-17-2008
    Location
    thailand
    MS-Off Ver
    2007
    Posts
    28
    My formula is

    =IF(IS18="","",IR17+1)

    I changed to

    =IF(IS18="",NA(),IR17+1)

    so I get #N/A instead of "" cells, I then edit the name range of my x values dynamic chart from JT column to IR column but the x assis shows all the points and not just the active ones.

    Btw the code works great and I can manage with it, don't know if you've any further suggestion regarding the formula but it's Christmas Eve and I certainly don't want to keep you busy, yours was the quickest response I ever had, I'm really surprised and I greatly appreciated.

    Have a good time, thank you so much.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    really need to see your formula for the named range.
    I would guess it is not taking into account that the NA's need to be excluded.

    Can you post workbook?

  8. #8
    Registered User
    Join Date
    12-17-2008
    Location
    thailand
    MS-Off Ver
    2007
    Posts
    28
    Thank you very much,

    I need to prepare a simplified workbook as the original is very heavy, right now I'm going to dinner so I'll to give you a break. As it is ready I will post it.

    thank you again

  9. #9
    Registered User
    Join Date
    12-17-2008
    Location
    thailand
    MS-Off Ver
    2007
    Posts
    28
    here's the workbook, I cut everything unnecessary still is big, I wrote a brief explanation on sheet1, hope it's understandable.

    I also hope to get it right with formulas.

    Again, when I fill the array I162:J171 in sheet1 I'd like to automatically copy the array HN164:IN173 in sheet2 (that contains formulas) and paste values on the very same array so that data will not be modified by further inputs.

    Well, if you feel I'm asking too much don't hesitate to tell me, I will post these last requests in a new thread, of course take your time, it's holiday now.

    Thank you and Merry Christmas
    Last edited by robbi100; 01-03-2009 at 08:02 AM. Reason: found a solution for a question I made

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    The XValues named range would become.

    =OFFSET(calc!$IR$4,0,0,COUNT(calc!$IR:$IR)-2,1)

  11. #11
    Registered User
    Join Date
    12-17-2008
    Location
    thailand
    MS-Off Ver
    2007
    Posts
    28
    Nice! So I got two solutions, via macro and via formula.

    Many thanks Andy

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1