+ Reply to Thread
Results 1 to 10 of 10

Copy cells from selected range of workbook1 to the first empty row in a table in workbook2

  1. #1
    Registered User
    Join Date
    07-10-2017
    Location
    SSD Samurai
    MS-Off Ver
    2016
    Posts
    8

    Copy cells from selected range of workbook1 to the first empty row in a table in workbook2

    I cry "UNCLE!"

    Goal of the macro is that it gets data from a specific set of cells (always the same range) from workbook1 and paste it to the first empty cell in a column of password-protected workbook2. It will then save both files and close workbook2.

    Here's what i've assembled so far:

    Please Login or Register  to view this content.
    Researched and found that the Run Time Error 9 means i've somehow misnamed or misdirected the macro at the "lRow" portion.

    Help would be greatly appreciated.

    Thank you.
    Last edited by AliGW; 07-11-2017 at 03:52 AM. Reason: Codetags added by moderator.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Copy cells from selected range of workbook1 to the first empty row in a table in workb

    You could start by replacing Workbooks("workbook2") with ThisWorkbook.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-10-2017
    Location
    SSD Samurai
    MS-Off Ver
    2016
    Posts
    8

    Re: Copy cells from selected range of workbook1 to the first empty row in a table in workb

    Tried, the entire line (where lRow is) went red.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Copy cells from selected range of workbook1 to the first empty row in a table in workb

    What exactly did you try?

    PS Could you use code tags when posting code?

  5. #5
    Registered User
    Join Date
    07-10-2017
    Location
    SSD Samurai
    MS-Off Ver
    2016
    Posts
    8

    Re: Copy cells from selected range of workbook1 to the first empty row in a table in workb

    Like indents and the like?
    lRow = ThisWorkbook .Worksheets("Tab1") .Cells(Worksheets("Tab1") .Rows.Count, 2).End(xlUp) .Row
    That line went red.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Copy cells from selected range of workbook1 to the first empty row in a table in workb

    Try this.
    Please Login or Register  to view this content.
    PS The reason your code is turning red, which indicates a syntax error, is that you appear to have added a bunch of spaces after the '.' in the code.

  7. #7
    Registered User
    Join Date
    07-10-2017
    Location
    SSD Samurai
    MS-Off Ver
    2016
    Posts
    8

    Re: Copy cells from selected range of workbook1 to the first empty row in a table in workb

    Will do that when i get back to work, ser.

    Crossing my fingers re fix!

  8. #8
    Registered User
    Join Date
    07-10-2017
    Location
    SSD Samurai
    MS-Off Ver
    2016
    Posts
    8

    Re: Copy cells from selected range of workbook1 to the first empty row in a table in workb

    Got this:
    438Error.png

    Error occurred at the code boxed in yellow:
    CodeError.png

    Only changed the filename and password as required.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Copy cells from selected range of workbook1 to the first empty row in a table in workb

    Remove the dot in front of Rows.Count.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-10-2017
    Location
    SSD Samurai
    MS-Off Ver
    2016
    Posts
    8

    Re: Copy cells from selected range of workbook1 to the first empty row in a table in workb

    Got a Run-Time Error 9, fixed it by swapping the wbSource & wbTarget.

    Added a function to save and close wbTarget.

    IT'S ALIVE!!! Full cred goes to you, Norie!

+ 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. Find value from Workbook1 in Workbook2, HOffset and copy range data
    By Dill Pickle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-17-2016, 09:46 PM
  2. How to bring data from workbook1 to workbook2 by comparing values of workbook2
    By amethystfeb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2013, 09:38 AM
  3. [SOLVED] macro for copy data Workbook1 and paste to Workbook2
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-09-2013, 11:22 AM
  4. VBA - Copy row from workbook1 to workbook2 based on string matching
    By TravisNeedham in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-09-2012, 12:50 PM
  5. Data from workbook1 to workbook2 every week but in different place in workbook2
    By cheelie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2007, 06:26 PM
  6. Replies: 1
    Last Post: 05-18-2005, 09:06 AM
  7. [SOLVED] autom update cells from Workbook1 to Workbook2
    By Bruno01 in forum Excel General
    Replies: 0
    Last Post: 01-28-2005, 08: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