Forum Discussion

Diane1970's avatar
Diane1970
Copper Contributor
Apr 11, 2023

Inserting Multiple rows after each change in data

Morning, trying to insert 25 rows after each change in data i.e. employee #

 

1 Reply

  • Diane1970 

    Sub insert()
    
    Dim i As Long
    Dim k As Integer
    
    For i = 2 To 10000
    
    If Cells(i + 1, 1).Value <> Cells(i, 1).Value Then
    
    For k = i + 1 To i + 25
    Rows(k).insert
    Next k
    i = k - 1
    
    Else
    End If
    
    Next i
    
    
    End Sub

    Maybe with these lines of code. In the attached file you can click the button in cell C1 to run the macro.

Resources