+ Reply to Thread
Results 1 to 9 of 9

Run-Time Error '1004'

  1. #1
    Registered User
    Join Date
    08-24-2011
    Location
    Washington, USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Run-Time Error '1004'

    I have a Macro that was created by someone else with no notes. The macro moves information from one spreadsheet (A) to separate tabs on another spreadsheet (B).

    I am trying to add a new tab on spreadsheet (B)

    I copied one of the other tab macros within the big macro and changed the tab name to the new tab name and it will not work.

    The first macro works when you step into it, it will go to the "_om" tab in (B) and paste the information even though it says "_om2". The second macro is the one I created, and when it gets to "_pc" it gives me an error.

    Run-TIme error '1004': The text you entered is not valid reference or defined name

    Please Login or Register  to view this content.
    Is there a way to designate the _pc as a name. I was told to use a Dim ?? As ?? statement. If that is correct how would you state that?
    Attached Files Attached Files
    Last edited by omakbigd; 08-29-2011 at 01:02 PM.

  2. #2
    Registered User
    Join Date
    08-23-2011
    Location
    Exeter, England
    MS-Off Ver
    Excel 2003 (Work), 2007 (Home)
    Posts
    18

    Re: Run-Time Error '1004'

    The reference in Application.Goto Reference:="_om2" refers to a named range not a worksheet.

    In the original, I'm guessing there is a named range "_om2" on sheet "_om" (which is why it works, despite the reference in the macro not matching the sheet name).

    In your macro, it is looking for a range named "_pc", which presumably doesn't exist.

  3. #3
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Run-Time Error '1004'

    You need a line of code like this:
    Please Login or Register  to view this content.
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  4. #4
    Registered User
    Join Date
    08-24-2011
    Location
    Washington, USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Run-Time Error '1004'

    So the line of code would state

    Please Login or Register  to view this content.
    Last edited by Mordred; 08-25-2011 at 01:57 PM.

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Run-Time Error '1004'

    Hi omakbigd, please use code tags around all code, even if it is just one line.

    I added them for you this time but remember to use them in the future.

    Thank you.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  6. #6
    Registered User
    Join Date
    08-24-2011
    Location
    Washington, USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Run-Time Error '1004'

    How do I name a range _pc with in a Sheet pc_? I am trying to learn this on the fly.

    Thanks

  7. #7
    Registered User
    Join Date
    08-24-2011
    Location
    Washington, USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Run-Time Error (Changed)

    I made some changes to the code and am now getting a different error.

    The new error is Run-time error '1004' Reference is not valid

    The line I added is,
    Please Login or Register  to view this content.
    The line after this is the bug.






    Please Login or Register  to view this content.
    Last edited by omakbigd; 08-25-2011 at 02:44 PM.

  8. #8
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Run-Time Error '1004'

    I took a look at your workbooks, and the one with the code modules is a bit of a mess. There's a lot that could be done to clean things up, but it would take me a while to wrap my head around what your trying to do. It looks like most of it has to do with copying, pasting and deleting data. What I need to know is which sub routine contains the code you'd like modified. I searched for the added line:
    Please Login or Register  to view this content.
    and couldn't find it in any of your code modules. In the attached book, I consolidated all of the modules into one module, and I need you to let me know:
    1) which routine needs modification
    2) which book to modules should be in
    Attached Files Attached Files

  9. #9
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Run-Time Error '1004'

    This is my own two cents, well, probably only one cent. Your code needs to be completely redone in my opinion. I've stepped through what you have from the following point
    Please Login or Register  to view this content.
    I didn't get an error but it is impossible to step through all your lines of code because of the multiple workbook selections and range selections / activations. This, coupled with tlafferty's (correct) statement
    the code modules is a bit of a mess
    makes me think that it may be easier for those that will help if you explain the processes of the workbook. If you step through the requirements with the forum, you should have a complete project in know time. Otherwise, your fix will be part guessing by the forum members such as tlafferty and perhaps too much work (time wise) for the kind volunteers.


    Unless, of course, tlafferty solved your problem for which you should just ignore my ramblings .

    Good Luck!

+ 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