#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Subtotal

Is there a way that when the value in a cell changes that I can input a row
over the changed value and subtotal the previous information? If the value
in cell 1 was 020 and continued until cell 5. A new value is entered in cell
6 030. I want the row to be inserted over the 030 and subtotal the
informtaion for 020.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Subtotal

Sub AAAtester1()
Dim lastrow As Long, formRow As Long
Dim i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
formRow = lastrow + 1
For i = lastrow To 2 Step -1
If Cells(i, 1) < Cells(i - 1, 1) Then
Cells(formRow, "B").Formula = "=SubTotal(9," & _
"B" & i & ":B" & formRow - 1 & ")"
Rows(i).Insert shift:=xlShiftDown
formRow = i
End If
Next
End Sub

Assumes you values are in column 1 (A) and the numbers to be subtotalled are
in column 2 (B)

Adjust to suit.

--
Regards,
Tom Ogilvy




"enyaw" wrote in message
...
Is there a way that when the value in a cell changes that I can input a

row
over the changed value and subtotal the previous information? If the

value
in cell 1 was 020 and continued until cell 5. A new value is entered in

cell
6 030. I want the row to be inserted over the 030 and subtotal the
informtaion for 020.



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
Subtotal To Include Item Description On Subtotal Line Tickfarmer Excel Discussion (Misc queries) 2 February 23rd 10 07:56 PM
sort macro, subtotal and add lines after subtotal David Excel Discussion (Misc queries) 1 August 29th 09 10:56 AM
pasting to subtotal lines without replacing hidden -non-subtotal l harleydiva67 Excel Discussion (Misc queries) 1 October 12th 06 06:02 PM
Bolding the subtotal lines automaticlly When using the Subtotal fu 06Speed6 New Users to Excel 2 October 5th 06 03:52 PM
Subtotal of Subtotal displays Grand Total in wrong row Thomas Born Excel Worksheet Functions 5 January 6th 05 01:46 PM


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