Unhide rows on another sheet when cell is populated

povictory

New Member
Joined
May 28, 2015
Messages
41
Hello,

Looking for some VBA help on this issue - Have two sheets (Sheet1 and Sheet2). On Sheet1, I want to make it so that populating cell N10 will unhide rows 10-19 on Sheet2...If N10 is blank on Sheet1, then rows 10-20 on Sheet2 will be hidden. And then also on Sheet1, same situation for cell N11 - if it's populated, I want rows 20-29 on Sheet2 to be unhidden, but to be hidden in the event that N11 is blank.

Any assistance on this is greatly appreciated!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
You've got an overlap there on row 20 in your logic - if N10 is blank then row 20 will be hidden, but if N11 is populated it will be unhidden? Assuming you want the range to be rows 10-19 inclusive, see if this gives you what you want in the worksheet coode area for sheet 1.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("N10:N11"), Target) Is Nothing Then
        If Me.Range("N10") <> "" Then
            Worksheets("Sheet2").Rows("10:19").Hidden = False
        Else
            Worksheets("Sheet2").Rows("10:19").Hidden = True
        End If
        If Me.Range("N11") <> "" Then
            Worksheets("Sheet2").Rows("20:29").Hidden = False
        Else
            Worksheets("Sheet2").Rows("20:29").Hidden = True
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,787
Messages
6,126,901
Members
449,348
Latest member
Rdeane

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