+ Reply to Thread
Results 1 to 8 of 8

copy data from specific cells in Wb 1 sheet1 to cells in WB2 sheet1

  1. #1
    Registered User
    Join Date
    08-30-2012
    Location
    Ottawa
    MS-Off Ver
    Excel 2007
    Posts
    59

    copy data from specific cells in Wb 1 sheet1 to cells in WB2 sheet1

    Hi guys,
    I am setting up a weekly report file and I need a macro that appends specific data from WB1 Sh1 to specific cells in WB2 Sh1. However, it must not override last week's data... so basically it changes column every time it's ran.

    I am not an expert @ VBA and this is what I found online... It copies data to rows instead of columns and when ran again, it opies data to the next row. I need the reverse - copy to columns instead of rows. I tried altering the formula, but couldn't get it to work. Hope you can help me out.

    Please Login or Register  to view this content.
    Thanks,
    Amar.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: copy data from specific cells in Wb 1 sheet1 to cells in WB2 sheet1

    Please Login or Register  to view this content.
    INTO
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-30-2012
    Location
    Ottawa
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: copy data from specific cells in Wb 1 sheet1 to cells in WB2 sheet1

    Hi AB33,
    It is still pasting horizontally instead of vertically. I assume that it has something to do w/ "wbkdes.Sheets("Test").Cells(nextrow, 1)...". Tried altering it, but I got an error message. I don't know what the correct syntax would be.

    Thanks,
    Amar.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: copy data from specific cells in Wb 1 sheet1 to cells in WB2 sheet1

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-30-2012
    Location
    Ottawa
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: copy data from specific cells in Wb 1 sheet1 to cells in WB2 sheet1

    Works like a charm. Mine didn't work because I tried "NextColumn" instead of "Nextcol".
    Appreciate your help, and thanks a lot.


    Regards,
    Amar.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: copy data from specific cells in Wb 1 sheet1 to cells in WB2 sheet1

    Amar,
    NextColumn" and "Nextcol are names of variables. Conventional coding recommend to name variables using words which closely resembles what the variable does.
    Please Login or Register  to view this content.
    finds the next empty row plus 1, hence the name next row.
    I have changed it to reflect that we are looking for next empty column. You could have used nextcol, or nextcolumn, but the syntax which is the important bit is the opposite of next row.

  7. #7
    Registered User
    Join Date
    08-30-2012
    Location
    Ottawa
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: copy data from specific cells in Wb 1 sheet1 to cells in WB2 sheet1

    I'm kinda a VBA newb, and I'm learning from examples and reading online. But your quick explanation helped me understand this bit of code. I thought it was pointing specifically to column B; but instead, it's looking for the next empty column.
    If you don't mind, I'd like to ask another question...How would I make it point to a specific cell, in the master spreadsheet? I.e. Instead of B1, let's say C5 or any other cells.
    Again, I'd like to say that I need to alter the below code, but I'm not sure.

    Please Login or Register  to view this content.
    Thank you.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: copy data from specific cells in Wb 1 sheet1 to cells in WB2 sheet1

    Please Login or Register  to view this content.
    You do not have to find the next empty column if you want to paste your values in to a specific cell. Let' say,C2
    wbkdes.Sheets("Test").Range("C2") = wbksour.Sheets("Master").Cells(13, 1) 'Copies A13 into Cell A2 of wbkdes.Sheets

    But if you want to copy in to next empty cell in C, you need to find which column/cell has the last data and then find the one the after
    This one finds you the next empty column regardless which column, be A, or B or Z. it will find the next empty column in any data.
    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)

Tags for this Thread

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