Add rows

Closed
Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Hello,

My name is Nilin and am from chennai.
I have a data like below :

A1 B1 C1 D1
A2 B2 C2 D2
A3 B3 C3 D3

I would need a macro which can gimme a data as below

A1 B1 C1 D1
A1
A1
A2 B2 C2 D2
A2
A2
A3 B3 C3 D3
A3
A3



Could you please assist me in this

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
Sub InsertRow()
Dim lMaxRows As Long

    lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
    
    Do While (lMaxRows > 0)
        
        Rows(lMaxRows + 1 & ":" & lMaxRows + 2).Insert
        Cells(lMaxRows, "A").Copy
        
        Range(Cells(lMaxRows + 1, "A"), Cells(lMaxRows + 2, "A")).PasteSpecial
        
        lMaxRows = lMaxRows - 1
        
    Loop
End Sub