Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 505
Default Excel 2002: Macro for inserting empty rows

Hi,

I have the folowing table:

A B C D
E
Flight Fare Type
1 M21 2,250 1
2 H32 2,530 1
3 T30 850 2
4 Q41 750 2
5 C47 650 2
6 Q21 3,650 8
7 Q72 3,820 8
5000

Column C is sorted in ascending order.

May I know the marco code that I need to run in order to insert an empty row
when the type changes ?

If column C is now moved to column E, how you code should be modified ?


Thanks


Low


--
A36B58K641
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 703
Default Excel 2002: Macro for inserting empty rows

Hi

Look at this, just change the letter in the TargetCol variable to
change column:

Sub InsertRows()
TargetCol = "C"
StartRow = 2 'Headings in row 1
LastRow = Range(TargetCol & Rows.Count).End(xlUp).Row

For r = LastRow To StartRow + 1 Step -1
If Range(TargetCol & r).Value < Range(TargetCol & r - 1).Value
Then
Rows(r).Insert
End If
Next
End Sub

Hopes this helps.

---
Per

On 13 Apr., 14:39, Mr. Low wrote:
Hi,

I have the folowing table:

* * * * * * *A * * * * * * B * * * * * * * *C * * * * * * * * *D * * * * * *
* * * E
* * * * * *Flight * * * Fare * * * * *Type
1 * * * * M21 * * *2,250 * * * * * * *1
2 * * * * H32 * * * 2,530 * * * * * * 1
3 * * * * T30 * * * * *850 * * * * * * 2
4 * * * * Q41 * * * * 750 * * * * * * *2
5 * * * * C47 * * * * *650 * * * * * * 2
6 * * * * Q21 * * * 3,650 * * * * * * 8
7 * * * * Q72 * * * 3,820 * * * * * * 8
5000

Column C is sorted in ascending order.

May I know the marco code that I need to run in order to insert an empty row
*when the type changes ?

If column C is now moved to column E, how you code should be modified *?

Thanks

Low

--
A36B58K641


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
Excel 2002: How to condition format rows with empty cells ? Mr. Low Excel Discussion (Misc queries) 6 September 19th 07 06:51 AM
Macro Help- Inserting Blank Rows jack Excel Discussion (Misc queries) 3 January 16th 07 09:43 PM
How to eliminate empty rows in Excel 2002 worksheet ? Mr. Low Excel Discussion (Misc queries) 7 October 20th 06 11:21 AM
Macro to hide rows with empty cells tp58tp Excel Worksheet Functions 2 November 13th 04 02:01 PM
Inserting Blank Rows Macro? Michael Saffer Excel Worksheet Functions 2 November 9th 04 06:23 PM


All times are GMT +1. The time now is 02:10 AM.

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"