Add rows

Closed
nilin - Jul 22, 2010 at 09:36 AM
rizvisa1
Posts
4479
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
- Jul 22, 2010 at 02:12 PM
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

rizvisa1
Posts
4479
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
769
Jul 22, 2010 at 02:12 PM
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
0