+ Reply to Thread
Results 1 to 6 of 6

Copying data from an open workbook

  1. #1
    Forum Contributor
    Join Date
    09-05-2007
    Posts
    148

    Copying data from an open workbook

    I have some code that looks through my open workbooks, looks for a sheet called UK_3 and then copies the data from row 3 to the end and then pastes it into my current workbook, sheet1.

    Unfortunately it doesn't actually select and copy the data. Any idea what's wrong?

    Please Login or Register  to view this content.

    Thanks

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Copying data from an open workbook

    Hi

    Try this change and se if it helps

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    473

    Re: Copying data from an open workbook

    try selecting the workbook before attempting to copy so add this line in between your existing lines

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    09-05-2007
    Posts
    148

    Re: Copying data from an open workbook

    From what i've read, ThisWorkbook selects the workbook running the macro. I've used the line in other things similar to this and it's been OK. I'm not 100% though so it may be that.

    The thing is, the workbook in which I will be using the code will change so I don't really want to define the workbook name.

    I tried defining the current books name and checking if it is the cause of the problem but it just does the same thing.

    Any way around this?
    Last edited by thedon_1; 11-04-2011 at 09:22 AM.

  5. #5
    Forum Contributor
    Join Date
    09-05-2007
    Posts
    148

    Re: Copying data from an open workbook

    Quote Originally Posted by johncassell View Post
    try selecting the workbook before attempting to copy so add this line in between your existing lines

    Please Login or Register  to view this content.
    That seemed to do the trick, nice one!

  6. #6
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Copying data from an open workbook

    Hi,

    Try this sub instead.
    This makes no selections and is faster.

    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)

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