Anybody know how to use variables in the place of [10:70]?
When I try to use variable here it crashes.
[10:70].EntireRow.Hidden = True 'Hide All Rows from 10-70
Anybody know how to use variables in the place of [10:70]?
When I try to use variable here it crashes.
[10:70].EntireRow.Hidden = True 'Hide All Rows from 10-70
![]()
Please Login or Register to view this content.
Entia non sunt multiplicanda sine necessitate
Have you tried
Rows("10:70").Select
Selection.EntireRow.Hidden = True
Happy with my advice? Click on the * reputation button below
Shg:
Hmmm... this didn't seem to work
Heres the full code below, im fighting the formidable unhidden objects glitch in Excel 2010 and found a fix in blue below.
Just trying to clean up a little bit of redundancy in the code by using loops and variables.
The code shown in red is the last bit I need to use variables for, currently it is a manual input. Tried your suggestion, but it doesn't seem to work.
Private Sub CheckBoxSMT_Click()
Dim i As Long
Dim ChkStart As Integer
Dim ChkFinish As Integer
Dim RowStart As Long
Dim RowFinish As Long
ChkStart = 1
ChkFinish = 61
RowStart = 10
RowFinish = 70
'Checkboxes: 1-61
'Rows: 10-70
If CheckBoxSMT = True Then
For i = ChkStart To ChkFinish
With ActiveSheet.Shapes("CheckBox" & i)
.Visible = True
End With
Next
[10:70].EntireRow.Hidden = False 'Unhide All
'Rows(RowStart & ":" & RowFinish).Hidden = True
Else:
For i = ChkStart To ChkFinish
With ActiveSheet.Shapes("CheckBox" & i)
.Visible = False
End With
Next
[10:70].EntireRow.Hidden = True 'Hide All
'Rows(RowStart & ":" & RowFinish).Hidden = True
End If
For i = ChkStart To ChkFinish 'Reset Checkbox Position (Bug fix)
With ActiveSheet.Shapes("CheckBox" & i)
.Top = Range("G" & i + RowFinish - ChkFinish).Top
End With
Next
End Sub
It worked fine for me. Did you try it standalone as I wrote it on a clean worksheet?
Correction, this has been confirmed as a working solution to the problem.
Thank you shg. Good job.
Rows(RowStart & ":" & RowFinish).Hidden = True
You're welcome.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks