Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2002: How to condition format rows with empty cells ? | Excel Discussion (Misc queries) | |||
Macro Help- Inserting Blank Rows | Excel Discussion (Misc queries) | |||
How to eliminate empty rows in Excel 2002 worksheet ? | Excel Discussion (Misc queries) | |||
Macro to hide rows with empty cells | Excel Worksheet Functions | |||
Inserting Blank Rows Macro? | Excel Worksheet Functions |