Unhide next row in multiple column

rakupareek

New Member
Joined
Dec 29, 2023
Messages
34
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
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Make sure the cells in the range B5:B15 and F5:F15 are not locked, then put the following code in the sheet module of the P&L sheet. Change the password to suit (or delete that option if no password used).
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"
        Target.Offset(1).EntireRow.Hidden = False
    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
Thanks Kevin
Code is working fine
Now I want to addition in this code that
When I clear content/delete data from selected range i.e B5:B15, F5:F15 then entire row will be hide automatically
If I delete data from column B then nothing happen but when I delete data from both column then entire row will hide
Thanks in advance for your prompt reply
 
Upvote 0
OK, it's always best to explain your full requirements up front and not add them on later. Have a good think about it, and let us know what your total requirement will be now.
 
Upvote 0
When I delete data from column B and column F then blank row will be hide
 
Upvote 0
Hi cavin
Here is my full requirment
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 F5-F15

As well as when I delete data from same row in both column then blank row to be hide.
Please suggest me VBA code for this
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,953
Members
449,095
Latest member
nmaske

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