Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Finding the average of two generated totals

Good afternoon,

I am currently using the following code:

Dim r As Range

For Each r In
Sheet1.UsedRange.Columns(1).SpecialCells(xlCellTyp eConstants).Areas
With r(r.Rows.Count + 1).Resize(, 8)
.Value = .Offset(-1).Value
.Offset(, 1).Resize(, 1).Value = WorksheetFunction.Sum(r.Offset(, 1))
.Offset(, 3).Resize(, 1) = WorksheetFunction.Sum(r.Offset(, 3))
.Offset(, 4).Resize(, 1) = WorksheetFunction.Sum(r.Offset(, 4))
.Font.Bold = True
End With
Next r

to summarise groups of like transations (that are seperated by blank rows)
by calculating the totals and values of each set and placing them in the row
below said group of transactions
eg: (bold doesn't seem to come out, the bottom row is the totals/summary)

DATE QTY B/S PRICE Gross Sale CUR ACC SERVICE
20090727 16997 S 66.5 1130300.5 GBX DEFAULT DMA
20090727 48606 S 66.5 3232299 GBX DEFAULT DMA
20090727 10000 S 66.5 665000 GBX DEFAULT DMA
20090727 58316 S 66.5 3878014 GBX DEFAULT DMA
20090727 133919 S 266 8905613.5 GBX DEFAULT DMA

This process is repeated for each group of transactions (20+) that are on
the worksheet.

However, my Price column total is not meant to be a sumtotal, but instead
the average which is the Gross Sales/QTY.

Is there a way I can modify my code to do that?

Would really appreciate any help or suggestions that can be given.

Regards,

PVANS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Finding the average of two generated totals

Instead of using worksheetfunction.sum(), try worksheetfunction.average().



PVANS wrote:

Good afternoon,

I am currently using the following code:

Dim r As Range

For Each r In
Sheet1.UsedRange.Columns(1).SpecialCells(xlCellTyp eConstants).Areas
With r(r.Rows.Count + 1).Resize(, 8)
.Value = .Offset(-1).Value
.Offset(, 1).Resize(, 1).Value = WorksheetFunction.Sum(r.Offset(, 1))
.Offset(, 3).Resize(, 1) = WorksheetFunction.Sum(r.Offset(, 3))
.Offset(, 4).Resize(, 1) = WorksheetFunction.Sum(r.Offset(, 4))
.Font.Bold = True
End With
Next r

to summarise groups of like transations (that are seperated by blank rows)
by calculating the totals and values of each set and placing them in the row
below said group of transactions
eg: (bold doesn't seem to come out, the bottom row is the totals/summary)

DATE QTY B/S PRICE Gross Sale CUR ACC SERVICE
20090727 16997 S 66.5 1130300.5 GBX DEFAULT DMA
20090727 48606 S 66.5 3232299 GBX DEFAULT DMA
20090727 10000 S 66.5 665000 GBX DEFAULT DMA
20090727 58316 S 66.5 3878014 GBX DEFAULT DMA
20090727 133919 S 266 8905613.5 GBX DEFAULT DMA

This process is repeated for each group of transactions (20+) that are on
the worksheet.

However, my Price column total is not meant to be a sumtotal, but instead
the average which is the Gross Sales/QTY.

Is there a way I can modify my code to do that?

Would really appreciate any help or suggestions that can be given.

Regards,

PVANS


--

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
use sub-totals and average in same calculation Sherry L Excel Worksheet Functions 0 January 26th 08 06:56 PM
Access totals, sum, average phil access Excel Discussion (Misc queries) 1 July 14th 05 10:45 PM
Calculations using totals generated in Pivot Tables fnov Excel Discussion (Misc queries) 0 March 3rd 05 07:17 AM
Finding Procedure which generated error LS[_2_] Excel Programming 3 April 12th 04 06:58 AM
Finding Totals...Continued LC[_3_] Excel Programming 0 July 24th 03 10:51 PM


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