-Excel 2013
-Windows 7 Professional
I would like my scroll button to hide the same rows in specific Worksheets.
I'm new to VBA so I used the Record Macro trick, however the constant switching the screen does causes the application to freeze. I wrote the code to the point where it hides the rows I need on a single page, can anyone tell me what I need to add to make it effect all pages without the page switching?
Any help would be greatly appreciated!
-Windows 7 Professional
I would like my scroll button to hide the same rows in specific Worksheets.
I'm new to VBA so I used the Record Macro trick, however the constant switching the screen does causes the application to freeze. I wrote the code to the point where it hides the rows I need on a single page, can anyone tell me what I need to add to make it effect all pages without the page switching?
Any help would be greatly appreciated!
Code:
Private Sub SpinButton1_Change()
If SpinButton1.Value = 30 Then
Rows("10:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 29 Then
Rows("10:10").Select
Selection.EntireRow.Hidden = False
Rows("11:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 28 Then
Rows("11:11").Select
Selection.EntireRow.Hidden = False
Rows("12:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 27 Then
Rows("12:12").Select
Selection.EntireRow.Hidden = False
Rows("13:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 26 Then
Rows("13:13").Select
Selection.EntireRow.Hidden = False
Rows("14:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 25 Then
Rows("14:14").Select
Selection.EntireRow.Hidden = False
Rows("15:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 24 Then
Rows("15:15").Select
Selection.EntireRow.Hidden = False
Rows("16:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 23 Then
Rows("16:16").Select
Selection.EntireRow.Hidden = False
Rows("17:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 22 Then
Rows("17:17").Select
Selection.EntireRow.Hidden = False
Rows("18:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 21 Then
Rows("18:18").Select
Selection.EntireRow.Hidden = False
Rows("19:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 20 Then
Rows("19:19").Select
Selection.EntireRow.Hidden = False
Rows("20:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 19 Then
Rows("20:20").Select
Selection.EntireRow.Hidden = False
Rows("21:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 18 Then
Rows("21:21").Select
Selection.EntireRow.Hidden = False
Rows("22:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 17 Then
Rows("22:22").Select
Selection.EntireRow.Hidden = False
Rows("23:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 16 Then
Rows("23:23").Select
Selection.EntireRow.Hidden = False
Rows("24:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 15 Then
Rows("24:24").Select
Selection.EntireRow.Hidden = False
Rows("25:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 14 Then
Rows("25:25").Select
Selection.EntireRow.Hidden = False
Rows("26:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 13 Then
Rows("26:26").Select
Selection.EntireRow.Hidden = False
Rows("27:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 12 Then
Rows("27:27").Select
Selection.EntireRow.Hidden = False
Rows("28:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 11 Then
Rows("28:28").Select
Selection.EntireRow.Hidden = False
Rows("29:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 10 Then
Rows("29:29").Select
Selection.EntireRow.Hidden = False
Rows("30:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 9 Then
Rows("30:30").Select
Selection.EntireRow.Hidden = False
Rows("31:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 8 Then
Rows("31:31").Select
Selection.EntireRow.Hidden = False
Rows("32:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 7 Then
Rows("32:32").Select
Selection.EntireRow.Hidden = False
Rows("33:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 6 Then
Rows("33:33").Select
Selection.EntireRow.Hidden = False
Rows("34:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 5 Then
Rows("34:34").Select
Selection.EntireRow.Hidden = False
Rows("35:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 4 Then
Rows("35:35").Select
Selection.EntireRow.Hidden = False
Rows("36:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 3 Then
Rows("36:36").Select
Selection.EntireRow.Hidden = False
Rows("37:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 2 Then
Rows("37:37").Select
Selection.EntireRow.Hidden = False
Rows("38:38").Select
Selection.EntireRow.Hidden = True
End If
If SpinButton1.Value = 1 Then
Rows("38:38").Select
Selection.EntireRow.Hidden = False
End If
End Sub