+ Reply to Thread
Results 1 to 5 of 5

Assign macro to paste data in a different place each time

  1. #1
    Registered User
    Join Date
    06-02-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    4

    Assign macro to paste data in a different place each time

    Hi everyone,

    This is a little difficult to explain but hopefully it will make sense....

    I have workbook1 sheet1 with data that is entered into columns A and B. Then on workbook1 sheet2 and sheet3 I have formulae in columns A and B which depend on the values entered in Sheet1.

    I then have a workbook2, which I run a macro to copy the values from workbook1 into as follows:

    Workbook1, Sheet2, column A goes to Workbook2, Sheet1 column A
    Workbook1, Sheet2, column B goes to Workbook2, Sheet2 column A
    Workbook1, Sheet3, column A goes to Workbook2, Sheet3 column A
    Workbook1, Sheet3, column B goes to Workbook2, Sheet4 column A

    This works fine. However, the final data here is always copied into column A. When I change the original data entered in workbook1 sheet1 for a new trial, is it possible for that final data to end up in the B columns of workbook2? And so on for every new trial.....

    So simply put, is there a way that if the cursor starts in a certain column before running a macro, then that will let all the resultant data to be entered into that column.

    Thanks in advance,

    Pedro

  2. #2
    Registered User
    Join Date
    06-02-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Assign macro to paste data in a different place each time

    Please Login or Register  to view this content.
    Last edited by romperstomper; 06-03-2011 at 08:14 AM. Reason: add code tags

  3. #3
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: Assign macro to paste data in a different place each time

    Hi

    I am assuming that all the columns will remain in alignment, so the following code only finds the last column once, but you could calculate the last column for each sheet if necessary

    Please Login or Register  to view this content.
    --
    Regards
    Roger Govier
    Microsoft Excel MVP

  4. #4
    Registered User
    Join Date
    06-02-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Assign macro to paste data in a different place each time

    Hi,

    I am not familiar with VBA, but i have pasted your code in replace of mine and it comes up with the run time error, there appears to be a problem with row 5 of coding

    Set wb1 = Workbooks("Workbook1.xlsm")


    Thanks

  5. #5
    Valued Forum Contributor
    Join Date
    07-17-2005
    Location
    Abergavenny, Wales, UK
    MS-Off Ver
    XL2003, XL2007, XL2010, XL2013, XL2016
    Posts
    608

    Re: Assign macro to paste data in a different place each time

    Quote Originally Posted by Pedro's PhD View Post
    Hi,

    I am not familiar with VBA, but i have pasted your code in replace of mine and it comes up with the run time error, there appears to be a problem with row 5 of coding
    Set wb1 = Workbooks("Workbook1.xlsm")
    Thanks
    I assumed the macro was being held in Workbook1, hence I named it as xlsm not xlsx.
    Change to
    Set wb1 = Workbooks("Workbook1.xlsx")

+ 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