Abigal
Abigal

Reputation: 143

Hide rows in a worksheet based on a cell value in different worksheet using VBA

I am trying to Hide rows 24 to 26 of a worksheet called "RS" if the value of cell H37 of a worksheet called "calculation sheet" is below 15,000

I have tried to use/combine formulas within VBA as previsouly used personally & on this forum but it didn't work. I am not too sure about the if function.

Thanking you in advance for your help. Abs

Upvotes: 0

Views: 967

Answers (2)

Scott Holtzman
Scott Holtzman

Reputation: 27249

Place this code in the Worksheet module for the "Calculation Sheet".

This code will fire every time a calculation is made on the Calculation Sheet.

Private Sub Worksheet_Calculate()

    Worksheets("RS").Rows("24:26").EntireRow.Hidden = Me.Range("H37").Value < 15000

End Sub

Upvotes: 1

Something like this should do it if you don't need anything to happen if H37 on the "calculated fields" sheet is >= 15,000

Sub test()

If Sheets("calculation sheet").Range("H37").Value < 15000 Then

Sheets("RS").Rows("24:26").EntireRow.Hidden = True

End If

End Sub

Upvotes: 1

Related Questions