Unhide next row in multiple column

rakupareek

New Member
Joined
Dec 29, 2023
Messages
38
Office Version
  1. 2016
Platform
  1. Windows
Hi
I have a protected worksheet named "P&L
In which 1-4 rows are headings
And row 5-15 available for data entry
I have made drop-down list in range B5-B15 for expenses and F5-F15 for income
Column C and G for Amount
At the start row 6-15 are hide
And row 5 is first row and being always unhide
My question is....
When I select data from drop-down in range B5-B15 next row automatic unhide.
Same rule will apply on range D5-D15
Please suggest me VBA code for this
 
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.CountLarge = 1 And Not Intersect(Range("B5:B15,F5:F15"), Target) Is Nothing Then
        On Error GoTo Escape
        Application.EnableEvents = False
        Me.Unprotect Password:="123"
        
        If Cells(Target.Row, 2) & Cells(Target.Row, 6) <> "" Then
            Target.Offset(1).EntireRow.Hidden = False
        ElseIf Cells(Target.Row, 2) & Cells(Target.Row, 6) = "" And Target.Row > 5 Then
            Target.EntireRow.Hidden = True
        End If
        
    End If
Continue:
    Application.EnableEvents = True
    Me.Protect Password:="123"
    Exit Sub
Escape:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume Continue
End Sub
 
Upvote 0
Solution

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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