Macro is not working

Closed
Nery - Feb 26, 2015 at 10:29 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Mar 2, 2015 at 11:56 AM
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 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Mar 2, 2015 at 11:56 AM
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
0