Occasional Contributor

Trouble getting sheet to move to next page and to the previous sheet using buttons in Excel

10 Replies


When you click one of the buttons, it changes the value of cell B3 on the Schedule sheet.

This causes the Worksheet_Change event procedure to run, and this calls ScheduleRefresh.

The ScheduleRefresh macro has a loop For WeekCol = 5 To 23 Step 3 ... Next WeekCol.

The second time through this loop, WeekCol equals 8.

The code adds a new sheet, and tries to rename it to the value of Cells(110, WeekCol). But Cells(110, 8), i.e. cell H110, is empty. This causes an error.

Perhaps some of these steps shouldn't occur - can you explain?

@Hans Vogelaar 

This excel program was downloaded from Excel freelancers website and I really like how it works. I really don't know why this happens and I try to find the root cause of it. If there anything in vba code that doesn't need to be there, can you suggest any changes to it that will as normal? Thanks.




It looks like the code and sheet layout don't match anymore. I suspect that extra columns have been inserted for the first day (columns G, H and I). Therefore, that day does not conform to the regular structure that the code expects.

Oh, I see it now. I did add those columns H, G, I. How can I include those columns in the macro code?


Do you want those extra columns for all days of the week, or just for the first day?

All days of the week please


That will require a MAJOR rewrite of the code. Stay tuned.

Ok. Geeze. I didn't mean for it to be that bad. I'm sorry causing all this extra work.
best response confirmed by tnvolsfan (Occasional Contributor)


See if this works for you.


Yes! That works for me! I appreciate your time! Again, thanks!!