+ Reply to Thread
Results 1 to 5 of 5

VBA Copy and paste when cell changes

  1. #1
    Registered User
    Join Date
    03-28-2013
    Location
    thailand
    MS-Off Ver
    Excel 2003
    Posts
    25

    VBA Copy and paste when cell changes

    I have a spreadsheet which automatically upgrades itself periodically by pulling data from a website.

    Whenever cell A1 data changes, I need to have A2:A10 copied and paste to the last available column. So end of the day I will have about 1000 columns of end of minute data in my spreadsheet in rows 2:10.

    Example.
    Live data A1 updating periodically
    When there are any change in a cell A1, the VBA will copy cells A2:A10 and paste it in B2:B10 (which is the last available column)
    At the next update in cell A1, the VBA will copy A2:A10 and paste it in C2:C10 (which is the next available empty column.

    I manage to do the cut and paste with the following.



    Please Login or Register  to view this content.
    can someone help me include the worksheet_change for cell A1 so that the whole macro runs when A1 changes. I am confused with including PRIVATE SUB worksheet_change

    What changes must I do to the VBA such that the updated cells are pasted on the right most available column. The above VBA always paste updated column on column B after moving old columns to the right.

    Moderator Note:

    Pls use code tags around your code next time as per forum rules.
    Last edited by Fotis1991; 10-04-2013 at 03:39 AM.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA Copy and paste when cell changes

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-28-2013
    Location
    thailand
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: VBA Copy and paste when cell changes

    Hi, When I try to run this VBA it ask me to name the macro which then tell me invalid procedure name.

    What must i add to run this macro in a sheet?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA Copy and paste when cell changes

    Hi, you place the macro in a worksheet object and then the macro is triggered by changing a cell on the worksheet. You cannot "run" these macros as you would a standard one.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Copy and paste when cell changes

    FWIW:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 6
    Last Post: 07-27-2013, 09:02 AM
  2. Replies: 8
    Last Post: 07-08-2013, 06:03 AM
  3. [SOLVED] Copy cell A1 and paste value into B1 if B1 has content, paste to B2...etc
    By mhopke in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2012, 09:39 PM
  4. How to select cell C1, copy paste then C2, copy paste then C3 etc
    By s45yth in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-07-2011, 07:15 AM
  5. Copy and Paste macro needs to paste to a changing cell reference
    By loulou in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2005, 07:06 AM

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