+ Reply to Thread
Results 1 to 7 of 7

Macro to copy filtered rows into new individual worksheets. Runtime Error 1004- line 25

  1. #1
    Registered User
    Join Date
    04-27-2013
    Location
    US
    MS-Off Ver
    Office365
    Posts
    4

    Macro to copy filtered rows into new individual worksheets. Runtime Error 1004- line 25

    I am attempting to copy filtered rows into new independent worksheets. I understand that one could find various versions of this code around the threads - but as I'm trying to learn this better - I was hoping someone might explain why the macro stalls at line 25 (ActiveSheet.Name = Left(UListValue, 30) It returns "Runtime Error 1004. I would like to understand my mistake so I won't make it in the future. Thanks to all!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Macro to copy filtered rows into new individual worksheets. Runtime Error 1004- line

    Hi J_Lee_M,

    Welcome to the forum!!

    Two reasons I can think of are that firstly (and most probably) there's no value being assigned to the UListValue variable. Test this by putting the variable in a message box i.e. MsgBox UListValue just before trying to rename the tab. The second is that there is one or more illegal characters in the UListValue variable that is causing the error, but I'd say this is less likely as the error message in that case specifically states that this is the problem.

    BTW - a tab can have a maximum of 31 characters so I'm guessing your code should be Left(UListValue, 31)?

    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    04-27-2013
    Location
    US
    MS-Off Ver
    Office365
    Posts
    4

    Re: Macro to copy filtered rows into new individual worksheets. Runtime Error 1004- line

    Thank you Robert! I apologize for being dense - but could you clarify "Test this by putting the variable in a message box i.e. MsgBox UListValue just before trying to rename the tab"? Maybe this is where I'm messing up - but I was under the impression that the Macro (not me) would be renaming each new sheet to the unique variable stored in the UList.

    Thanks for your time - I certainly appreciate it.
    Last edited by J_Lee_M; 05-22-2013 at 01:02 AM. Reason: To clarify Last sentence, as it was too vague

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Macro to copy filtered rows into new individual worksheets. Runtime Error 1004- line

    I was under the impression that the Macro (not me) would be renaming each new sheet to the unique variable stored in the UList
    Correct. The issue I'm guessing is that there's a blank cell in Col. A that is being added to the UList collection which the macro then tries to rename a tab as such which is why it's failing.

    See if incorporating these lines of code where you create the array (collection) does the trick:

    Please Login or Register  to view this content.
    Though I don't know all of your code, there may be conflicts the next time you run the macro as each tab in a workbook must be unique.

    HTH

    Robert

  5. #5
    Registered User
    Join Date
    04-27-2013
    Location
    US
    MS-Off Ver
    Office365
    Posts
    4

    Re: Macro to copy filtered rows into new individual worksheets. Runtime Error 1004- line

    Worked like a charm. Thank you again, so much, Robert. I appreciate the help.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to copy filtered rows into new individual worksheets. Runtime Error 1004- line

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  7. #7
    Registered User
    Join Date
    04-27-2013
    Location
    US
    MS-Off Ver
    Office365
    Posts
    4

    Re: Macro to copy filtered rows into new individual worksheets. Runtime Error 1004- line

    Sorry and thank you. I was just too excited about having the problem solved (and making one function of my job ridiculously easier) that I completely forgot about hitting "solved". I will remember to do so in the future. Additionally - I made sure to go back and hit Trebor76's reputation star - for his great help. Thanks for the reminders.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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