Hi all - my first post here.
I have a worksheet with a series of sequential numbers in Column F, typically running from about 25 or 30 in Row 6, and increasing by 1 in each row below that, to a maximum number in Row 85. I'd like to hide the rows in which the number in Column F is greater than 90. The procedure needs to run whenever the sheet is calculated. The values in the column can change based on either of 2 inputs on another sheet, so I also need the procedure to unhide rows in which the number is 90 or less. The code I have so far is:
... But it's not working. I get an "application-defined or object-defined" error. Can anyone see what I'm missing here?
BTW - I've also tried calling this procedure from Sheet1 (using the Worksheet_Change event), but I can't get it to run the code on Sheet2. To be clear - there are 2 inputs on Sheet1, and I want Sheet2's row-unhiding/hiding procedure to run if either input changes.
I have a worksheet with a series of sequential numbers in Column F, typically running from about 25 or 30 in Row 6, and increasing by 1 in each row below that, to a maximum number in Row 85. I'd like to hide the rows in which the number in Column F is greater than 90. The procedure needs to run whenever the sheet is calculated. The values in the column can change based on either of 2 inputs on another sheet, so I also need the procedure to unhide rows in which the number is 90 or less. The code I have so far is:
VBA Code:
Private Sub Worksheet_Calculate()
Dim Cl As Range
For Each Cl In Range("F6:F85")
Cl.EntireRow.Hidden = False
Cl.EntireRow.Hidden = Cl.Value > 90
Next Cl
End Sub
... But it's not working. I get an "application-defined or object-defined" error. Can anyone see what I'm missing here?
BTW - I've also tried calling this procedure from Sheet1 (using the Worksheet_Change event), but I can't get it to run the code on Sheet2. To be clear - there are 2 inputs on Sheet1, and I want Sheet2's row-unhiding/hiding procedure to run if either input changes.