Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Subtotal multiple columns and ...

This is my current code:

Sub subTotal()

Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long
Dim botCell As Range
Dim topCell As Range
Dim wks As Worksheet


Set wks = ActiveSheet

With wks
FirstRow = 2
.Rows(FirstRow).Insert
.Cells(FirstRow, "A").Value = "dummyVal"
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row


Set topCell = .Cells(LastRow, "A")
Set botCell = .Cells(LastRow, "A")
For iRow = LastRow To FirstRow + 1 Step -1
If .Cells(iRow, "A").Value = .Cells(iRow - 1, "A").Value
Then
Set topCell = .Cells(iRow - 1, "A")
Else

botCell.Offset(1, 0).EntireRow.Insert
botCell.Offset(1, 1).Formula _
= "=subtotal(9," & topCell.Offset(0, 1).Address(0,
0) _
& ":" & botCell.Offset(0, 1).Address(0, 0)
& ")"
botCell.Offset(1, 0).Value = "Subtotal: " &
botCell.Value

Set botCell = .Cells(iRow - 1, "A")
Set topCell = .Cells(iRow - 1, "A")
End If
Next iRow

.Rows(FirstRow).Delete

End With


End Sub

With the above this, I will need to modify to make the following
happen:

1. I will need to total Columns D - H for each group. (need loop
through an array, I suppose).
2. On Column I and Column J, the value is unique for each group. What
I need to do is to carry that value to the subtotal row and blank out
the rows that are not subtotal.

I appreciate your help.


Faye Larson
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 Multiple Columns DanaK Excel Worksheet Functions 3 October 26th 11 07:05 PM
subtotal on 2 columns moon11 Excel Discussion (Misc queries) 1 September 9th 06 05:33 AM
Subtotal multiple columns [email protected] Excel Programming 1 August 21st 06 08:27 PM
Subtotal by two columns at once Katherine Excel Discussion (Misc queries) 1 January 20th 05 08:19 PM
Subtotal and Total Columns gfinch[_3_] Excel Programming 2 January 7th 04 05:35 PM


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