If include the row below after the last name of every person, automatically the first visible name row should be hidden

13 views Asked by At

I have a list of names that are repeated every week. Whenever I include a new week row, it automatically hides the above first row of that name:

enter image description here

and after hiding the previous row, the first visible row should be highlighted like:

enter image description here

I tried the below code but I am unable to hide the above row and highlight the first visible row after hidden the previous row of each name.

Sub InserEmptyRows()

Dim i As Long

Application.ScreenUpdating = False

For i = Cells(Cells.Rows.count, "D").End(xlUp).Row To 5 Step -1

If Cells(i, "D") <> Cells(i - 1, "D") Then Rows(i).Insert Shift:=xlDown

Next i
0

There are 0 answers