Insert Rows

  • I'm sure someone can help, I would like a macro to select every other row in a spreadsheet, and insert a row ahead of them. Any help would be greatly appreciated. I do not know a lot of VBA, but I'm trying to learn.

  • Hi,


    try the code


  • Hello kb


    Select the range you wish to expand and run this:


    Code
    Sub AddRowsOdd()
        Dim iRow As Integer
        For iRow = 1 To Selection.Rows.Count * 2
            If iRow Mod 2 = 1 Then
                Selection.Rows(iRow).Rows.Insert
            End If
        Next iRow
    End Sub

    If I've been helpful, let me know. If I haven't, let me know that too. 

  • Here's a slightly different approach (actually two, because I wasn't sure if you wanted the final result to have alternating blank rows, or every third row blank.) The first produces alternating blank rows. The second every third row is blank.


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!