Help! Hiding rows in sheet2 based on values in sheet1

Oti

New Member
Joined
Aug 23, 2011
Messages
5
Hello everyone. I'm new to vba and am looking for some guidance. I am using excel2003. Here's my problem...
sheet1 cells a1 to a16 contain a list of parts to be built. sheet1 cells b1 to b16 each contain a drop down list limiting values to "yes" or "no". "no" in sheet1 B1 needs to hide rows 16 and 17 on sheet2. "no" in sheet1 B2 needs to hide rows 18-20 on sheet2., "no" in sheet1 B3 needs to hide sheet2 rows 21-29, etc. What is the proper way to do this?
A "yes" value i sheet1 should also make sure that the rows are visible. Is this even possible?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Welcome to MrExcel.

Example for the first 3 cells:

Code:
Sub Test()
    With Worksheets("Sheet1")
        Worksheets("Sheet2").Rows("16:17").Hidden = .Range("B1").Value = "no"
        Worksheets("Sheet2").Rows("18:20").Hidden = .Range("B2").Value = "no"
        Worksheets("Sheet2").Rows("21:29").Hidden = .Range("B3").Value = "no"
    End With
End Sub
 
Upvote 0
Thanks Andrew! This works! Next question...is there a way for this to update automatically when switching from sheet1 to sheet2?
 
Upvote 0
i cant do vba so i tend to look for non-vba solutions.

if you point a cell from each row you want to hide on sheet at the trigger cells on sheet 1, you can then apply a filter on that column to hide what you don't want to see. I think you can hide this coloumn and the row with the filter to keep things tidy. I just tried a simple test an it seemed to work.
 
Upvote 0
Put this in the module for Sheet2:

Code:
Private Sub Worksheet_Activate()
    With Worksheets("Sheet1")
        Me.Rows("16:17").Hidden = .Range("B1").Value = "no"
        Me.Rows("18:20").Hidden = .Range("B2").Value = "no"
        Me.Rows("21:29").Hidden = .Range("B3").Value = "no"
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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