How to insert columns with macro

  • Thread starter Thread starter THE GAME
  • Start date Start date
T

THE GAME

I've got a spreadsheet that I need to modify. One of the fields says "number
of photos" and I want to take that number, and insert the number of rows I
want right beneath, then continue to the next item in the field and do the
same thing.

In the other columns, I want to copy the data that's there to the new
row(s).

I can't find a command to automatically insert a row, though.

Thanks in advance.
 
This will insert the rows for you.

Sub InsertRows()
Dim LastRow As Long
Dim i As Long
Application.ScreenUpdating = False
LastRow = Range("A65536").End(xlUp).Row
For i = LastRow To 1 Step -1
If IsNumeric(Range("A" & i)) Then
Range("A" & i).Offset(1, 0).Resize(Range("A" & i)).EntireRow.Insert
End If
Next 'i
Application.ScreenUpdating = True
End Sub

Regards

Trevor
 
Back
Top