Auto unhide the rows below if a value is entered in row above

Mieke01

New Member
Joined
Feb 13, 2017
Messages
6
Hello,
I am a real novice to VBA but am trying to learn. I would like to include a macro in my spreadsheets that automatically unhide the rows below, one by one, if there is a value in the row above. eg if a date is entered in B11, row 12 is revealed when the user goes across to cell C11. The best I got so far is that all the rows are unhidden (the range is 11 to 59) but not one to one. This is what I got so far:
Private Sub Worksheet_Change(ByVal Target As Range)
If Sheets("Expense Form").Range("A10") = 0 Then

Application.ScreenUpdating = False

Else

Dim rng As Range

For Each rng In Range("A11:A60")
Select Case rng.Value
Case Is <> 0
Cells(rng.Row, 1).EntireRow.Hidden = False

Case Else
Cells(rng.Row, 1).EntireRow.Hidden = True

End Select
Next rng
Application.ScreenUpdating = True

End If

End Sub

But that isn't working really.

Thank you for your help.

Mieke
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You were talking about cell B11 but in the code you enter all your ranges in column A

also in case a cell has a value you want the next line to be visible. would be Cells(rng.Row+1, 1) not Cells(rng.Row, 1)
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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