Inserting Row after data change
Hi
Try this:
Sub InsertRows()
StartRow = 2 'Headings in row 1
TargetCol = "AH"
EndRow = Cells(StartRow, TargetCol).End(xlDown).Row
r = EndRow
Do Until r = StartRow
If Cells(r, TargetCol).Value < Cells(r - 1, TargetCol).Value Then
Rows(r).Insert
Rows(r).Insert
End If
r = r - 1
Loop
End Sub
Regards,
Per
"ATanker62" skrev i meddelelsen
...
Hello all
I have a spreadsheet that has a list of cities in column AH. I would like
to make a macro that will read the value in the cell, compair it to the
next
cell down and if the cities name is different then to insert two rows.
Thanks
Example
S Beloit
S Beloit
San Antonio
Sioux Falls
Sioux Falls
To become
S Beloit
S Beloit
San Antonio
Sioux Falls
Sioux Falls
|