Vba to hide rows based on a cell within another worksheet

tomwhi

New Member
Joined
May 13, 2013
Messages
35
Hello,

Please can I ask for your help again.

I am looking for VBA to Hide Rows (37:38), Based on value ("No") of a cell (D26) in another worksheet (Control Center). If cell D26 in worksheet "Control Center" is blank or "Yes", I do NOT want hide the row.

Thanks,
Tom
 
Hi Momentman,

There is a Worksheet_Calculate() event procedure in excel. procedure is triggered by any change in a formula.
The below code should work for you.

Private Sub Worksheet_Calculate()
Dim MyRange As Range
Set MyRange = Sheets("Control Center").Range("C26")
If MyRange.Value = "No" Then
Sheets("Output").Rows("37:38").EntireRow.Hidden = True
Else
Sheets("Output").Rows("37:38").EntireRow.Hidden = False
End If
End Sub

Thanks,
Mahesh
You can simplify that Calculate code down to this...

Code:
Private Sub Worksheet_Calculate()
  Sheets("Output").Rows("37:38").EntireRow.Hidden = Sheets("Control Center").Range("C26").Value = "No"
End Sub
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top