LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Insert line sum rows

Hi

I have been working on inserting a line whenever the cost centre
changes, then summing the next 10 columns to the right. I have found
some code which inserts a row and sums the like totals of only one
column. Can someone help with extending it out 10 columns. I don't
want to use the subtotal function for a range of reasons. Ta

eg
AA 2 5
AA 2 4
Total 4 9

BB 4 6
BB 4 3
Total 8 9

Regards

Chad

Sub sumrow()
Dim Start As Range, Cell As Range
Set Start = Range("C1")
Set Cell = Range("B2")
Do While Not IsEmpty(Cell)
If Cell.Value < Cell(0).Value Or _
Cell(1, 0).Value < Cell(0, 0).Value Then
Cell.EntireRow.Insert
Cell(0, 2).Formula = "=sum(" & _
Range(Start, Cell(-1, 2)).Address & ")"
Set Start = Cell(1, 2)
End If
Set Cell = Cell(2, 1)
Loop
Cell(1, 2).Formula = "=sum(" & _
Range(Start, Cell(0, 2)).Address & ")"

End Sub
 
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
Insert rows: Formats & formulas extended to additonal rows Twishlist Excel Worksheet Functions 0 October 22nd 07 04:23 AM
Insert New Line Clare Excel Discussion (Misc queries) 4 July 6th 06 03:40 PM
Insert two rows in one line of code? quartz[_2_] Excel Programming 4 November 10th 05 04:31 PM
Insert each line in a new row BrianB Excel Discussion (Misc queries) 0 May 31st 05 03:14 PM
My rows are off by one row, ie. data on line 10 should line up wi. lindamari New Users to Excel 1 April 19th 05 04:25 PM


All times are GMT +1. The time now is 12:33 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"