Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Inserting Row after data change

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default 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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to change default font size when inserting comments Gary M Excel Discussion (Misc queries) 3 February 28th 07 04:59 PM
Inserting time into cell in excel and have it not change iculus Excel Programming 3 March 10th 06 03:30 PM
Inserting Change Document Date dhspeller Excel Discussion (Misc queries) 1 February 5th 06 03:27 PM
Inserting Rows with the change event active KobusD Excel Programming 2 September 29th 05 04:34 PM
Macro to change Chart Range when inserting a column Mark Charts and Charting in Excel 1 September 13th 05 01:12 PM


All times are GMT +1. The time now is 02:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"