Worksheet run time error 1004 - LoopIndex breaking down

grexcelman

Board Regular
Joined
Mar 1, 2015
Messages
50
Not sure why this is breaking but I have a spreadsheet with dozens of tabs that require updating through this macro loop. It indexes the first and last pages, 30 to 80 but once it reaches the 39th tab, it breaks. I've tried moving the potential bad tab(running it separately at times) but it doesn't change the break. Any thoughts on where this code or my spreadsheet could be getting tripped up?

Code:
Worksheets("Monthly Trend").Select

' determine current bounds
    Dim StartIndex, EndIndex, LoopIndex As Integer
    StartIndex = Sheets("Monthly Trend").Index
    EndIndex = Sheets("Transactions").Index
 
    For LoopIndex = StartIndex To EndIndex
    Sheets(LoopIndex).Select
    
       RetrieveSheet
       
    Next LoopIndex
 
Last edited:

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
is it the same tab that breaks, what number is the Tab, whats its name
 
Upvote 0
is it the same tab that breaks, what number is the Tab, whats its name


The tab number remains 39 and that doesn't change even when I swap the order around. I thought maybe it was the tab name, given it had spaces in it? That didn't seem to make a difference.
 
Upvote 0
is there any protection or strange cell merges
 
Upvote 0
No protection but there are plenty of data groupings, not sure how you mean by "strange" cell merges but there are no unique cell mergers on anyone particular page. All the pages have the same formatting properties and that includes cell mergers. Again, this runs about 10 sheets before it breaks. When I close out the module and return to the spreadsheet, I can run it separately without error. Note, this is running an essbase retrieve function on each sheet but I can't seem to duplicate the error when I run it individually.
 
Upvote 0
Maybe a DoEvents at the end of each loop ?
 
Upvote 0
You can't select a hidden sheet. Is the 39th sheet hidden?
 
Upvote 0
You can't select a hidden sheet. Is the 39th sheet hidden?

There are hidden sheets in the document but I don't know why that would trip it up if I'm referencing by name the first and last sheets. ...would that throw it off regardless?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top