Insert blank row on two conditions
Posted
by
lost_my_wallet_in_el_segundo
on Super User
See other posts from Super User
or by lost_my_wallet_in_el_segundo
Published on 2013-10-24T21:52:24Z
Indexed on
2013/10/24
21:58 UTC
Read the original article
Hit count: 120
I have a spreadsheet with a large number of rows. There are two rows grouped together (for each customer). In column A, the first row has an account number. The second row should be blank.
The spreadsheet has lots of customers listed where there is no second row. I need to insert a blank line to create a second row for each customer that doesn't have one.
Here is the VBA script I cobbled together, but it gets a syntax error.
Sub Macro1()
'
' Macro1 Macro
'
For myrow = 1 To Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
If Cells(myrow, 1) <> "" and Cells(myrow+1, 1) <> ""
Then
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End Sub
© Super User or respective owner