Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Need some VB script, please

I have 22 different classes in Column F, each class may have 1-25 item rows.
I need to locate the last row of each class and insert a row below it (22 new
rows inserted throughout the sheet). Then I need it to sum the dollar amounts
located in Column AI in the new row for all of the items in each class.

I hope you can help.

Thank you,

~Robert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 341
Default Need some VB script, please

1) make sure each column has a title (column F will be called class)
2) sort by column F (class) ascending
3) use data subtotals
at each change in Class
use function SUM
apply to columns AI (dollars)

then hit OK

Excel adds the subtotals and extra rows for you.
You can get a group level summary by clicking 1,2,3 on the left

--
Allllen


"rlee1999" wrote:

I have 22 different classes in Column F, each class may have 1-25 item rows.
I need to locate the last row of each class and insert a row below it (22 new
rows inserted throughout the sheet). Then I need it to sum the dollar amounts
located in Column AI in the new row for all of the items in each class.

I hope you can help.

Thank you,

~Robert

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Need some VB script, please

Sub SumClasses()
Dim iLastRow As Long
Dim i As Long
Dim tmp

iLastRow = Cells(Rows.Count, "F").End(xlUp).Row
tmp = ""
For i = iLastRow To 1 Step -1
If Cells(i, "F").Value < tmp Then
tmp = Cells(i, "F").Value
Rows(i + 1).Insert
Cells(i + 1, "F").Formula = "=SUMIF(F1:F" & i & ",""" & tmp &
""",AI1:AI" & i & ")"
End If
Next i

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rlee1999" wrote in message
...
I have 22 different classes in Column F, each class may have 1-25 item

rows.
I need to locate the last row of each class and insert a row below it (22

new
rows inserted throughout the sheet). Then I need it to sum the dollar

amounts
located in Column AI in the new row for all of the items in each class.

I hope you can help.

Thank you,

~Robert



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
Can any help with a little script Danny Boy via OfficeKB.com Excel Programming 6 January 29th 06 11:47 AM
VB script help - please!! Anthony Excel Discussion (Misc queries) 1 July 13th 05 01:19 AM
VB script help..please !! Anthony Excel Worksheet Functions 2 June 5th 05 03:26 PM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM
VB Script Help Quanchi[_4_] Excel Programming 4 November 12th 03 01:19 PM


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