auto hide and unhide

bleeet

Board Regular
Joined
May 11, 2009
Messages
208
Office Version
  1. 2013
Platform
  1. Windows
Hi guys

I am trying to make a sheet unhide the row below when someone inputs a value in a certain cell. and if they delete that value the same row will got back to hidden. I have this code which hides the row but how to I make it hide the row if the value in the cell is deleted.

Code:
Public Sub Worksheet_Change(ByVal Target As Range)

 If Target.Address(False, False) = "A2" Then
        With Sheet19
            .Rows(3).EntireRow.Hidden = False

Also if it isn't too much can you also tell me how I can make this happen to a long rang of cells in certain rows where the bottom row unhides when the top cell has a value and hides when there is no value in the cell above? Or do I have to keep repeating the above code for each cell?


thanks
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
not 100% sure what you are trying to accomplish.

this code will displayrow 3 if you enter something in cell A2. if you delete A2 then if will hide row 3

Code:
Public Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A2")) Is Nothing Then
        r = Target.Row
        If Target = "" Then Rows(r + 1).EntireRow.Hidden = True Else Rows(r + 1).EntireRow.Hidden = False
    End If
End Sub

hth,

Ross
 
Upvote 0
not 100% sure what you are trying to accomplish.

this code will displayrow 3 if you enter something in cell A2. if you delete A2 then if will hide row 3

Code:
Public Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A2")) Is Nothing Then
        r = Target.Row
        If Target = "" Then Rows(r + 1).EntireRow.Hidden = True Else Rows(r + 1).EntireRow.Hidden = False
    End If
End Sub

hth,

Ross

Thanks so much

sorry I was unclear. what I am trying to do is in a certain range of rows for example rows 3-20 when a user types a value in a certain cell in row 3 then row 4 unhides and if they type a value in a certain cell in row 4 then row 5 unhides and then continues until row 20

then in a different range of rows say rows 30-40 the same thing happens for those rows


I hope this makes sense

thanks
 
Upvote 0
just change the range

Code:
Public Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A2:A50")) Is Nothing Then
        r = Target.Row
        If Target = "" Then Rows(r + 1).EntireRow.Hidden = True Else Rows(r + 1).EntireRow.Hidden = False
    End If
End Sub

hth,
Ross
 
Upvote 0
Yea, so sorry I just realized that myself


thanks so much again

:)
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,287
Members
449,149
Latest member
mwdbActuary

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