Hiding rows after cell entry

XrayLemi

Board Regular
Joined
Aug 1, 2018
Messages
153
Office Version
  1. 365
Platform
  1. Windows
Hello everyone. Hope you are all well and safe.

Here is my dilemma. I need to hide rows after a value is entered. All the code I have seen posted here will hide every row after a cell entry is made. What I need is, if I add a date in column "E" next to the name Bill like in the picture, I want every row with the name Bill in column "D" to be hidden EXCEPT the row with the date. Later if I add a date in column "E" next to the name Gus, all the rows with Gus, except the row with the date, will be hidden. Once the date is added in column "E" that name will never be added to the list again. So, I won't have to worry about hiding future entries with that name.

The name here is generic. There will be first, last and maybe middle names as well. I don't know if it matters, but all the entries in columns A-D are auto filled by entries in other workbooks. the only manual entry is the date in column "E". Hope this

Thank you in advance,
Jim
 

Attachments

  • Name List.png
    Name List.png
    107.3 KB · Views: 11

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Will the col E cells for a given name always be empty except for the one row you don't want hidden?
 
Upvote 0
Please, try this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim LR As Long, NP As Range
  If Target.Count > 1 Then Exit Sub
  If Target.Column <> 5 Or Target.Value = "" Or Target.Offset(, -1).Value = "" Then Exit Sub
  LR = Cells(Rows.Count, 4).End(3).Row
  For Each NP In Range("D2:D" & LR).SpecialCells(xlVisible)
   Rows(NP.Row).Hidden = Cells(NP.Row, 4) = Target.Offset(, -1).Value And NP.Row <> Target.Row
  Next NP
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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