#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 78
Default Subtotal Problem

I have data on a worksheet through functions and macros, postions of data
changes all the time, no a specific range can be define, i am known to
subtotal function but for now its not enough

i have two major fields for my data
first is sector and and is company

Column A Column B
Sector Company

i need subtotal Average for every company (same co. could be on multiple
rows) but the grand total Average for sector (Because average result for the
whole data and average result of subtotal of companies are entirely
different) i have 34 different sectors and around 250 companies and have to
average on 15 columns

i have made the data available already sorted through sector and then
company and have 2 blanks rows after each company through function and macro

can anyone help if this could be done through any funtion or macro, it would
be really great
thanks


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Subtotal Problem

Look at SUMPRODUCT:

For average by Company within Sector

=SUMPRODUCT(--(A2:A100=Sector),--(B2:B100=Company),(C2:C100))/SUMPRODUCT(--(A2:A100=Sector),--(B2:B100=Company))

For average by Sector

=SUMPRODUCT(--(A2:A100=Sector,(C2:C100))/SUMPRODUCT(--(A2:A100=Sector))


where column C are values to be averaged

Replace Sector & company with cell addresses

HTH

"Salman" wrote:

I have data on a worksheet through functions and macros, postions of data
changes all the time, no a specific range can be define, i am known to
subtotal function but for now its not enough

i have two major fields for my data
first is sector and and is company

Column A Column B
Sector Company

i need subtotal Average for every company (same co. could be on multiple
rows) but the grand total Average for sector (Because average result for the
whole data and average result of subtotal of companies are entirely
different) i have 34 different sectors and around 250 companies and have to
average on 15 columns

i have made the data available already sorted through sector and then
company and have 2 blanks rows after each company through function and macro

can anyone help if this could be done through any funtion or macro, it would
be really great
thanks


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 78
Default Subtotal Problem

thanks
but my problem is that data is called through macro and rows are not
specific for subtotals, i tried a macro through which i move on to some
extent but result are not accurate, i am not much familiar with macros, yes
can alter to some extent;

- sector average base on companies in that sector is not accurate
- how to handle #Div/0! error within that macro

below is the macro i am using

Sub test()
Range("a3:p470").Select
Selection.Subtotal GroupBy:=Array(1), Function:=xlAverage,
TotalList:=Array(7, 8, 9, 10, 11), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Selection.Subtotal GroupBy:=Array(2), Function:=xlAverage,
TotalList:=Array(7, 8, 9, 10, 11), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True
End Sub


"Toppers" wrote:

Look at SUMPRODUCT:

For average by Company within Sector

=SUMPRODUCT(--(A2:A100=Sector),--(B2:B100=Company),(C2:C100))/SUMPRODUCT(--(A2:A100=Sector),--(B2:B100=Company))

For average by Sector

=SUMPRODUCT(--(A2:A100=Sector,(C2:C100))/SUMPRODUCT(--(A2:A100=Sector))


where column C are values to be averaged

Replace Sector & company with cell addresses

HTH

"Salman" wrote:

I have data on a worksheet through functions and macros, postions of data
changes all the time, no a specific range can be define, i am known to
subtotal function but for now its not enough

i have two major fields for my data
first is sector and and is company

Column A Column B
Sector Company

i need subtotal Average for every company (same co. could be on multiple
rows) but the grand total Average for sector (Because average result for the
whole data and average result of subtotal of companies are entirely
different) i have 34 different sectors and around 250 companies and have to
average on 15 columns

i have made the data available already sorted through sector and then
company and have 2 blanks rows after each company through function and macro

can anyone help if this could be done through any funtion or macro, it would
be really great
thanks


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 78
Default Subtotal Problem

thanks
but my problem is that data is called through macro and rows are not
specific for subtotals, i tried a macro through which i move on to some
extent but result are not accurate, i am not much familiar with macros, yes
can alter to some extent;

- sector average base on companies in that sector is not accurate
- how to handle #Div/0! error within that macro

below is the macro i am using

Sub test()
Range("a3:p470").Select
Selection.Subtotal GroupBy:=Array(1), Function:=xlAverage,
TotalList:=Array(7, 8, 9, 10, 11), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Selection.Subtotal GroupBy:=Array(2), Function:=xlAverage,
TotalList:=Array(7, 8, 9, 10, 11), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True
End Sub



"Toppers" wrote:

Look at SUMPRODUCT:

For average by Company within Sector

=SUMPRODUCT(--(A2:A100=Sector),--(B2:B100=Company),(C2:C100))/SUMPRODUCT(--(A2:A100=Sector),--(B2:B100=Company))

For average by Sector

=SUMPRODUCT(--(A2:A100=Sector,(C2:C100))/SUMPRODUCT(--(A2:A100=Sector))


where column C are values to be averaged

Replace Sector & company with cell addresses

HTH

"Salman" wrote:

I have data on a worksheet through functions and macros, postions of data
changes all the time, no a specific range can be define, i am known to
subtotal function but for now its not enough

i have two major fields for my data
first is sector and and is company

Column A Column B
Sector Company

i need subtotal Average for every company (same co. could be on multiple
rows) but the grand total Average for sector (Because average result for the
whole data and average result of subtotal of companies are entirely
different) i have 34 different sectors and around 250 companies and have to
average on 15 columns

i have made the data available already sorted through sector and then
company and have 2 blanks rows after each company through function and macro

can anyone help if this could be done through any funtion or macro, it would
be really great
thanks


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 command problem Martin B Excel Worksheet Functions 1 November 26th 06 01:34 PM
Subtotal problem. Very strange! Carl Excel Worksheet Functions 0 October 6th 06 04:07 PM
Subtotal is still problem is 2003 SP2 Norm Lundquist Excel Discussion (Misc queries) 0 August 10th 06 04:22 PM
Excel Subtotal problem gmasson Excel Worksheet Functions 1 January 23rd 06 07:18 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 11:37 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"