+ Reply to Thread
Results 1 to 3 of 3

Macro to copy contents of one page to another results in runtime error 1004

  1. #1
    Registered User
    Join Date
    03-23-2010
    Location
    Victoria, Australia
    MS-Off Ver
    Excel 2002
    Posts
    2

    Macro to copy contents of one page to another results in runtime error 1004

    I'm trying to build a code, to be run from a button, that copys the contents of one sheet and pastes it in another, then runs a code that deletes any rows that do not meet my specified criteria.

    I recorded a macro that does the copy paste function, which runs fine on its own, and i have the code that deletes the rows, on its own, with runs fine. If I put the copy code in before the delete code, we get runtime error 1004.

    Here is the code that is giving me grief:
    Please Login or Register  to view this content.
    The line with "Range("B2:D170").Select" is the line that becomes highlighted when the debug button is pressed.
    I have searched google extensively for a solution, but all seem to be irrelevant to my job.

    Could i call the prerecorded macro from the button, before the delete code is run? How would i do this?

    Regards,
    Ryan Akers

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Macro to copy contents of one page to another results in runtime error 1004

    It appears you have the code in a worksheet module. If so, when you have a Range call that is unqualified by a worksheet, it actually refers to the range on the worksheet containing the code, and since that sheet is not active, you cannot select a range on it. However, you don't need to select anything here anyway:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    03-23-2010
    Location
    Victoria, Australia
    MS-Off Ver
    Excel 2002
    Posts
    2

    Re: Macro to copy contents of one page to another results in runtime error 1004

    Thanks very much for your help. It works a treat.

+ 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