cambralenta
New Member
- Joined
- Nov 30, 2009
- Messages
- 23
Hello,
I'm using this BruceWayne code that works fine in the worksheet whith the command button. But, I want the macro to run in all sheets except were the command button is?
All sheets are password protected! Button is in Worksheet ("DATA").
Have tried, with many searches but i can't do it by my self!... Thanks
I'm using this BruceWayne code that works fine in the worksheet whith the command button. But, I want the macro to run in all sheets except were the command button is?
Code:
Sub RowsToHide()
Dim myVal As String
Dim mainRow As Long, tweakRow As Long
Dim hideRange As Range, showRange As Range
Dim row1 As Long, row2 As Long
mainRow = 38
myVal = Range("C9").Value
If myVal = 30 Then
Rows(mainRow - 30 & ":" & mainRow - 30 + myVal).EntireRow.Hidden = False
ElseIf myVal >= 1 And myVal <= 29 Then
tweakRow = mainRow - 30
row1 = (mainRow - (29 - myVal))
row2 = (mainRow - (30 - myVal))
Set hideRange = Rows(row1 & ":" & mainRow).EntireRow
Set showRange = Rows(tweakRow & ":" & row2).EntireRow
Debug.Print "For a value of " & myVal & ", we will hide range: " & hideRange.Address & ", and show range: " & showRange.Address
hideRange.Hidden = True
showRange.Hidden = False
ElseIf myVal = 0 Then
Rows(mainRow - 30 & ":" & mainRow).EntireRow.Hidden = True
End If
End Sub
Have tried, with many searches but i can't do it by my self!... Thanks
Last edited: