Excel VBA to hide rows based on cell value

Stuepef

Board Regular
Joined
Oct 23, 2017
Messages
128
Office Version
  1. 2021
Platform
  1. Windows
I am looking to write VBA to hide 2 rows on Sheet10 (code name) based on cell value on Sheet1 (code name). The logic I am looking for assistance on is the following:

If Sheet1 cell C33 does NOT = "Apple" then hide Sheet10 rows 108 & 109, but if cell C33 is blank, then do nothing.

Thank you!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Something like
Code:
   If Sheet1.Range("C33") <> "Apple" And Sheet1.Range("C33") <> "" Then
      Sheet10.Rows("108:109").Hidden = True
   End If
 
Upvote 0
@Fluff - How would I update the code you provided if I wanted rows 108 & 109 to be hidden across Sheets 10, 11 and 12?
 
Upvote 0
Just copy the line that hides the rows & change the sheet name
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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