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

Hi,

I created a macro to sort records, obtain a sub total then a grand total.
Easily done when creating a macro using the SubTotal function but to run the
macro for a new sheet holding different row count by row label, the subtotal
occurs at the wrong row break. I don't use VBA in Excel much but need a
simple way to do the following:

Name Number

Mark 1
Mark 1
Mark 1
Sub Total 3

Dan 2
Dan 2
Dan 2
Sub Total 6

Joyce 3
Joyce 3
Joyce 3
Sub Total 9

If I use the macro to run the following, it breaks it as:

Mark 1
Mark 1
Mark 1
Sub Total 3

Mark 1
Sub Total 1

Thanks

Norm





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Sub Total

Sometimes you can just change your range to point at the whole column instead of
specifying a starting row and an ending row.

ActiveSheet.Columns("A:E").Subtotal GroupBy:=1, Function:=xlCount, _
TotalList:=Array(2), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True

or if you can pick out a column that always has data:

dim myRng as range
with activesheet
set myrng = .range("a1:e" & .cells(.rows.count,"A").end(xlup).row)
end with

myrng.subtotal.....



Norman Belanger wrote:

Hi,

I created a macro to sort records, obtain a sub total then a grand total.
Easily done when creating a macro using the SubTotal function but to run the
macro for a new sheet holding different row count by row label, the subtotal
occurs at the wrong row break. I don't use VBA in Excel much but need a
simple way to do the following:

Name Number

Mark 1
Mark 1
Mark 1
Sub Total 3

Dan 2
Dan 2
Dan 2
Sub Total 6

Joyce 3
Joyce 3
Joyce 3
Sub Total 9

If I use the macro to run the following, it breaks it as:

Mark 1
Mark 1
Mark 1
Sub Total 3

Mark 1
Sub Total 1

Thanks

Norm


--

Dave Peterson

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
Duplicate Running Total Grand Total In Pivot Table Mathew P Bennett[_2_] Excel Discussion (Misc queries) 1 August 17th 08 03:13 AM
Excel 2002 : Any single button to get sub total and grand total ? Mr. Low Excel Discussion (Misc queries) 2 May 22nd 07 08:46 AM
Total column changes colors when total equals sum of other columns newstacy New Users to Excel 1 April 21st 07 09:00 PM
calculate count on 2006 total, 2005 total, etc... Amanda Deshotel Excel Worksheet Functions 6 September 28th 06 11:59 PM
Adding Data Using Multiple Worksheets to Total into a Grand Total Lillie Excel Worksheet Functions 1 April 19th 05 08:34 PM


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