Macro is not working

[Closed]
Report
-
Posts
2817
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 14, 2021
-
Hello,

The first time the macro worked, I was so happy! (I used it once)

Now is not working anymore, no idea why.

Can someone help me? I really need to save time (inserting more than 900 rows between employees.
A1: Nilda Perez
A2: Nilda Perez
A3: Nilda Perez
A4: Marcos Rubio
A5Marcos Rubio
A6: Marcos Aurelio
A7: Marcos Aurelio
A8 Maritza Santos
A9: Carmen Peralta
A10: Carmen Peralta
A11: Carme Peralta
A12: Carmen Peralta
A13: Luis O'Neil
(I need to add an empty row each time the name changes)
Thanks a bunch.

1 reply

Posts
2817
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 14, 2021
486
Hi Nery,

Try the following code:
Sub RunMe()
Dim lRow, x As Integer
lRow = Range("A1").End(xlDown).Row * 2
For x = 1 To lRow Step 1
    If Cells(x + 1, "A").Value = vbNullString Then Exit Sub
    If Cells(x, "A").Value <> Cells(x + 1, "A").Value Then
        Cells(x + 1, "A").EntireRow.Insert
        x = x + 1
    End If
Next x
End Sub


Best regards,
Trowa