G
Guest
Depending on the integer value displayed in cell L10, I'm trying to hide
unapplicable predefined sets of entire rows, just to make the computations
easier to follow.
For example, if cell L10 displays a value of 3 :myValue), then hide the
entire rows corresponding to myValue of 1, 2, 4, 5, 6, 7, 8, 9
If cell L10 displays a value of 7 :myValue), then hide the entire rows
corresponding to myValue of 1, 2, 3, 4, 5, 6, 8, 9. And so on.
Here is the simple macro that does not work:
Option Base
-------------------------------------------------------------------------------------------
Sub HideOtherScens (mySheet1, mySheet2, myValue)
' mySheet1 & mySheet2 are string arguments
' myValue is integer value in cell L10
'
Dim myName (1 To 9) As String
Dim i As Integer
'
myName (1) = mySheet1.Rows ("12:21") ' corresponds to myValue = 1
myName (2) = mySheet1.Rows ("22:31") ' corresponds to myValue = 2
.............................
myName (9) = mySheet2.Rows ("74:85") ' corresponds to myValue = 9
For i = 1 To 9
If myValue = i Then
myName (i).EntireRow.Hidden = False
Else
myName (i).EntireRow.Hidden = True
End If
Next i
End Su
-------------------------------------------------------------------------------------------
"Compile error: Invalid qualifier", and following the If statement myName is
highlighted.
Where did I go wrong ? Perhaps in the string array declaration ??
Your suggestions would be greatly appreciated.
unapplicable predefined sets of entire rows, just to make the computations
easier to follow.
For example, if cell L10 displays a value of 3 :myValue), then hide the
entire rows corresponding to myValue of 1, 2, 4, 5, 6, 7, 8, 9
If cell L10 displays a value of 7 :myValue), then hide the entire rows
corresponding to myValue of 1, 2, 3, 4, 5, 6, 8, 9. And so on.
Here is the simple macro that does not work:
Option Base
-------------------------------------------------------------------------------------------
Sub HideOtherScens (mySheet1, mySheet2, myValue)
' mySheet1 & mySheet2 are string arguments
' myValue is integer value in cell L10
'
Dim myName (1 To 9) As String
Dim i As Integer
'
myName (1) = mySheet1.Rows ("12:21") ' corresponds to myValue = 1
myName (2) = mySheet1.Rows ("22:31") ' corresponds to myValue = 2
.............................
myName (9) = mySheet2.Rows ("74:85") ' corresponds to myValue = 9
For i = 1 To 9
If myValue = i Then
myName (i).EntireRow.Hidden = False
Else
myName (i).EntireRow.Hidden = True
End If
Next i
End Su
-------------------------------------------------------------------------------------------
"Compile error: Invalid qualifier", and following the If statement myName is
highlighted.
Where did I go wrong ? Perhaps in the string array declaration ??
Your suggestions would be greatly appreciated.