Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Macro to add a blank row when a difference between rows is found

Hi All,

I would like to write a macro which selects a series of rows, sorts them by
a particular column and then adds a row whenever a difference bewteen the
rows for that particular column are found.

I can write the macrow which does the sorting but am struggling with adding
the line. I have googled this and have found many methods but unfortunately
I don't understand them enough to make them work for me - don't know which
variables I need to change etc.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Macro to add a blank row when a difference between rows is found

The following macro will insert a blank row above the current row if the
difference between the cell in Col A in the row and the cell above it is
greater than 1

Sub AddRow()
ColumntoCheck = "A"
For i = Cells(Rows.Count, ColumntoCheck).End(xlUp).Row To 2 Step -1
If ((Cells(i, ColumntoCheck) - Cells(i - 1, ColumntoCheck)) 1) Then
Cells(i, "A").EntireRow.Insert
' Cells(i, ColumntoCheck) = Cells(i - 1, ColumntoCheck) + 1
End If
Next i
End Sub

"Aus-JN" wrote:

Hi All,

I would like to write a macro which selects a series of rows, sorts them by
a particular column and then adds a row whenever a difference bewteen the
rows for that particular column are found.

I can write the macrow which does the sorting but am struggling with adding
the line. I have googled this and have found many methods but unfortunately
I don't understand them enough to make them work for me - don't know which
variables I need to change etc.

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
Hiding blank rows using a macro GJR3599 Excel Discussion (Misc queries) 1 March 20th 07 09:22 PM
Macro Help- Inserting Blank Rows jack Excel Discussion (Misc queries) 3 January 16th 07 09:43 PM
Sort Macro to Exclude Blank Rows? ScottPcola Excel Worksheet Functions 1 January 5th 06 07:10 PM
Delete blank rows Macro Richard Excel Discussion (Misc queries) 3 November 4th 05 08:02 AM
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 01:15 PM.

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

About Us

"It's about Microsoft Excel"