+ Reply to Thread
Results 1 to 9 of 9

Macro not working except in one tab, Must save and reopen to work in others.

  1. #1
    Forum Contributor
    Join Date
    01-25-2009
    Location
    Louisiana
    MS-Off Ver
    Excel 2007
    Posts
    177

    Macro not working except in one tab, Must save and reopen to work in others.

    I have a wierd issue. I have this macro for a workbook i use and if i run the macro in the first tab it runs and works fine. When i select the other tab and run it it gives me a debug error. If i close the worksheet save it and reopen it and run it in the other tab it runs fine.

    So in otherwords i have to run the macro in the tab desired, save it , and always close and reopen the file to run it in the other tabs. I know the code is correct because it runs flawlessly without errors but i must be missing something.

    If anyone can help that would really save me some time and efficiency.

    Also i currently have the macro to run on the active tab/worksheet. Can i have it run on multiple tabs? i have 15 20 and 30 tabs in this example file but in my real file i have many more milage intervals ( some tabs i would not want to select ). It gets tedious having to select one tab at a time, run the macro, rinse and repeat.


    For Example Run Macro First, in the first tab. It works perfectly. Go to the second tab and run the first macro. It gives a debug error. If you save the file and reopen it and go to teh second tab and run the macro again it works.


    Thanks for anyone that helps, File included below.
    Attached Files Attached Files
    Last edited by donnydorko; 10-17-2009 at 01:14 PM.

  2. #2
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: Macro not working except in one tab, Must save and reopen to work in others.

    To run it in multiple tabs, could go about that a couple ways.
    If it's a changing worksheet with additions, I'd go with something like:

    Please Login or Register  to view this content.
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  3. #3
    Forum Contributor
    Join Date
    01-25-2009
    Location
    Louisiana
    MS-Off Ver
    Excel 2007
    Posts
    177

    Re: Macro not working except in one tab, Must save and reopen to work in others.

    I see, that was more of a minor issue, the main problem is having the macro stop working after running it in each tab. reopening it is a pain.

  4. #4
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: Macro not working except in one tab, Must save and reopen to work in others.

    I replaced your FINDIT line with :
    Please Login or Register  to view this content.
    And it works on all the worksheets without reopening.
    I've never used FINDIT so I'm not sure how it determines which sheet it's running on, but that was your issue. FINDIT was not working after running once, and because it could not find "CAR", FINDIT.ROW was causing an error, since FINDIT was nothing.

  5. #5
    Forum Contributor
    Join Date
    01-25-2009
    Location
    Louisiana
    MS-Off Ver
    Excel 2007
    Posts
    177

    Re: Macro not working except in one tab, Must save and reopen to work in others.

    hmm , i put the code in replace of find it but i ran into a debug error.

    Could you perhaps reupload the file with the correction.


    The findit part in the first few lines of the codes objective was to sort by column C,D,E down to the row before car found in COlumn A.

    So essensitally row 3 to row 552 in this example, different files have different lengths so i wanted it to be dynamic. if Car is found in ROw 600 it will sort from 3 to row 599.

  6. #6
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: Macro not working except in one tab, Must save and reopen to work in others.

    Sorry, should have said add that in to replace the FINDIT line of code, then in the next couple lines there's a ...FINDIT.row - 1... which needs to be replaced with... x - 1

    Can't seem to attach it, this is the complete code:

    Please Login or Register  to view this content.
    Last edited by mewingkitty; 10-17-2009 at 01:17 PM.

  7. #7
    Forum Contributor
    Join Date
    01-25-2009
    Location
    Louisiana
    MS-Off Ver
    Excel 2007
    Posts
    177

    Re: Macro not working except in one tab, Must save and reopen to work in others.

    dont see attached , ill try to do what u said.

    Alright got it, works like a charm.

    Appreciate the help !

  8. #8
    Forum Contributor
    Join Date
    01-25-2009
    Location
    Louisiana
    MS-Off Ver
    Excel 2007
    Posts
    177

    Re: Macro not working except in one tab, Must save and reopen to work in others.

    last thing if possible, could you explain to me what the code you wrote is doing line for line ( i know its short so thats why im asking ).

    I am curious to know how it works in finding the row before the Car.
    Last edited by donnydorko; 10-17-2009 at 01:26 PM.

  9. #9
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: Macro not working except in one tab, Must save and reopen to work in others.

    See attached example of a few different ways to search for things.
    I've included explanations in the code for each different section.
    Hopefully that helps.

    mew!
    Attached Files Attached Files

+ 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