+ Reply to Thread
Results 1 to 3 of 3

Making sure an acceptable range is copied from one workbook to another.

  1. #1
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Making sure an acceptable range is copied from one workbook to another.

    I have this code that gives me 2 different errors. In workbook 1, the workbook with the macro, I allow the user to open workbook 2 and copy a worksheet to workbook 1.

    Please Login or Register  to view this content.
    My first problem is if workbook 2 has no data. Then I get an error from the first 2 lines basically saying null was found and I can't assign null to a variable. Is there code that gets around that issue? If I can see the workbook has no data I can just add in code that doesn't copy anything.

    The second problem is in line 5. The error is "Excel cannot complete this task with available resources. Choose less data or close other applications."

    Please Login or Register  to view this content.
    This occurs if the only cells in workbook 2 with data are A1, A2, B1, or B2. If I add data to column C or line 3 this problem goes away. Any idea what's going on here?

    Thanks in advance for any help.
    Last edited by 111StepsAhead; 01-16-2013 at 10:55 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Making sure an acceptable range is copied from one workbook to another.

    I don't know about the second error, but for the first one I know a solution. If you define last_Row and last_Column differently, you never get null (the lowest you can get is 1).
    Please Login or Register  to view this content.
    I took the code from here:
    http://www.rondebruin.nl/last.htm

    edit: maybe a possible solution to your other problem:
    Please Login or Register  to view this content.
    Last edited by RHCPgergo; 01-16-2013 at 10:41 AM.

  3. #3
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Making sure an acceptable range is copied from one workbook to another.

    Thanks RHCPgergo. You fixed both my problems. I was going to add that the file I am importing is an .XLSM. Maybe that has something to do with the import issue. Maybe not. Anyways, have a great day!


    edit:
    For my purposes I changed

    Please Login or Register  to view this content.
    to the following.

    Please Login or Register  to view this content.
    It was selecting all the rows with the first line.
    Last edited by 111StepsAhead; 01-16-2013 at 10:59 AM. Reason: Small code change.

+ 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