I have a long but simple VBA program that hides rows in a spreadsheet depending upon options. Everything works fine when I single step through the program using F8. However, that is not the case when I use a command button to execute. For example, there are eight rows each for Slots C, D and E. For the specific variables, the coding should hide none of C, 4 of D and all of E in workbooks '700G Relay Setting Calcs' and 'Logic Variables'. It does so successfully with single step using F8. When pressing the command button within the spreadsheet, it hides 5 instead of 4 D in workbook '700G Relay Setting Calcs', and none of D and only 3 of E in workbook 'Logic Variables'.
I don't understand how it would work using F8 but not work when runing the macro automatically. Any ideas on where to start looking for the issue? A sample portion of code follows:
'Unhide all rows in Worksheets "700G Relay Setting Calcs" and "Logic Variables"
Worksheets("700G Relay Setting Calcs").Rows("1:1000").Hidden = False
Worksheets("Logic Variables").Rows("1:100").Hidden = False
'Hide unavailable Slot C Output rows
For I = Range("C_Outputs").Value + Range("Num_C_Out").Value To Range("C_Outputs").Value + 7
Worksheets("700G Relay Setting Calcs").Rows(I).Hidden = True
Next I
For J = 45 + Range("Num_C_Out").Value To 52
Worksheets("Logic Variables").Rows(J).Hidden = True
Next J
'Hide unavailable Slot D Output rows
For I = Range("D_Outputs").Value + Range("Num_D_Out").Value To Range("D_Outputs").Value + 7
Worksheets("700G Relay Setting Calcs").Rows(I).Hidden = True
Next I
For J = 53 + Range("Num_D_Out").Value To 60
Worksheets("Logic Variables").Rows(J).Hidden = True
Next J
'Hide unavailable Slot E Output rows
For I = Range("E_Outputs").Value + Range("Num_E_Out").Value To Range("E_Outputs").Value + 7
Worksheets("700G Relay Setting Calcs").Rows(I).Hidden = True
Next I
For J = 61 + Range("Num_E_Out").Value To 68
Worksheets("Logic Variables").Rows(J).Hidden = True
Next J
Bookmarks