Excel VBA to Hide Rows

stmorrison

New Member
Joined
Nov 1, 2010
Messages
1
I have limited knowledge of VBA, but have determined it is needed to automate row hiding in my workbook with mulitple worksheets. I need help desparately! Here is what I need to accomplish:
On Worksheet 1, if I have a 0 or blank in cell C11, I need to hide rows 7, 14, and 21 of Worksheet 2.
Or on Worksheet 1, if I have a 0 or blank in cell C12, I need to hide rows 8, 15, and 22 of Worksheet 2.
Or - I will continue to insert other criteria too.

Worksheet 2 is being used to generate charts on Worksheet 3. Therefore based on certain criteria I am trying to automatically hide rows on worksheet 2 to eliminate gaps in my charts.

For what it is worth, I have tried the below VBA in worksheet 1. The first part works - this code will hide rows 8, 15, and 22 based on C12 input but I can't get other parts of the code to function.

If Target <> Range("C12") Then Exit Sub
Sheets("At A Glance").Rows.Hidden = False
Select Case Range("C12").Value
Case 0

Sheets("At A Glance").Rows("8").Hidden = True
Sheets("At A Glance").Rows("15").Hidden = True
Sheets("At A Glance").Rows("22").Hidden = True
or_
If Target <> Range("C11") Then Exit Sub
Sheets("At A Glance").Rows.Hidden = False
Select Case Range("C11").Value
Case 0

Sheets("At A Glance").Rows("7").Hidden = True
Sheets("At A Glance").Rows("14").Hidden = True
Sheets("At A Glance").Rows("21").Hidden = True
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,215,012
Messages
6,122,682
Members
449,091
Latest member
peppernaut

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