Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Search Columns For Change, Insert Blank Rows, and Sum Differen

Try this, with the sheet with the data being the active one.

Sub InsertRowsSums()
Dim iRow As Long
Dim iFirst As Long
Dim aColA As String
Dim aColB As String
iRow = 2
iFirst = 2
aColA = Cells(iRow, 1)
aColB = Cells(iRow, 2)
Do
iRow = iRow + 1
If Cells(iRow, 1) < aColA Or Cells(iRow, 2) < aColB Then
Rows(iRow & ":" & iRow + 1).Insert Shift:=xlDown
str1 = "D" & iFirst & ":D" & iRow - 1
Cells(iRow, 4).Formula = "=Sum(" & str1 & ")"
Cells(iRow, 4).Copy Range(Cells(iRow, 5), Cells(iRow, 7))
iRow = iRow + 2
iFirst = iRow
aColA = Cells(iRow, 1)
aColB = Cells(iRow, 2)
End If
Loop Until Cells(iRow, 1) = ""
End Sub

Hth,
Merjet


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Search Columns For Change, Insert Blank Rows, and Sum Differen

Thanks for the help! This will make things much easier.

"merjet" wrote:

Try this, with the sheet with the data being the active one.

Sub InsertRowsSums()
Dim iRow As Long
Dim iFirst As Long
Dim aColA As String
Dim aColB As String
iRow = 2
iFirst = 2
aColA = Cells(iRow, 1)
aColB = Cells(iRow, 2)
Do
iRow = iRow + 1
If Cells(iRow, 1) < aColA Or Cells(iRow, 2) < aColB Then
Rows(iRow & ":" & iRow + 1).Insert Shift:=xlDown
str1 = "D" & iFirst & ":D" & iRow - 1
Cells(iRow, 4).Formula = "=Sum(" & str1 & ")"
Cells(iRow, 4).Copy Range(Cells(iRow, 5), Cells(iRow, 7))
iRow = iRow + 2
iFirst = iRow
aColA = Cells(iRow, 1)
aColB = Cells(iRow, 2)
End If
Loop Until Cells(iRow, 1) = ""
End Sub

Hth,
Merjet



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
Search Columns For Change, Insert Blank Rows, and Sum Differen merjet Excel Programming 0 May 23rd 07 05:37 PM
Search Columns For Change, Insert Blank Rows, and Sum Differen merjet Excel Programming 0 May 23rd 07 05:36 PM
Search Columns For Change, Insert Blank Rows, and Sum Differen merjet Excel Programming 0 May 23rd 07 05:35 PM
Search Columns For Change, Insert Blank Rows, and Sum Different Co Bagman Excel Programming 5 May 23rd 07 04:09 PM
How do I insert blank rows between rows in completed worksheet? bblue1978 Excel Discussion (Misc queries) 1 October 26th 06 07:02 PM


All times are GMT +1. The time now is 08:29 AM.

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"