Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how to change default font size when inserting comments | Excel Discussion (Misc queries) | |||
Inserting time into cell in excel and have it not change | Excel Programming | |||
Inserting Change Document Date | Excel Discussion (Misc queries) | |||
Inserting Rows with the change event active | Excel Programming | |||
Macro to change Chart Range when inserting a column | Charts and Charting in Excel |