Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Calculating an average using VBA

Hello, Is there a way of calculating the average (or the maximum) of a range
within VBA without actually entering the formula in the spreadshhet.
Supposing I want to assign to a variable, the average or the maximum of the
numbers that reside in Column C from row 5 to ro 25.

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Calculating an average using VBA

Try worksheet change

Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyRange As Range
If Target.Count 1 Then Exit Sub
Set MyRange = Range("C5:C25")
If Not Intersect(Target, MyRange) Is Nothing Then
Range("A1").Value = WorksheetFunction.Max(MyRange)
Range("A2").Value = WorksheetFunction.Average(MyRange)
End If
End Sub


Mike


"Ben" wrote:

Hello, Is there a way of calculating the average (or the maximum) of a range
within VBA without actually entering the formula in the spreadshhet.
Supposing I want to assign to a variable, the average or the maximum of the
numbers that reside in Column C from row 5 to ro 25.

Thank you

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Calculating an average using VBA

Thank you

"Ben" wrote:

Hello, Is there a way of calculating the average (or the maximum) of a range
within VBA without actually entering the formula in the spreadshhet.
Supposing I want to assign to a variable, the average or the maximum of the
numbers that reside in Column C from row 5 to ro 25.

Thank you

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
Calculating an average Maggie Excel Worksheet Functions 1 August 22nd 08 03:50 AM
Calculating Average ub Excel Discussion (Misc queries) 2 July 16th 08 05:14 PM
Calculating Average Graham Excel Worksheet Functions 1 July 2nd 08 04:40 PM
Calculating the average Andy_Trow Excel Discussion (Misc queries) 3 July 27th 07 02:15 PM
Calculating a Temporary Average Gail Gurman Excel Discussion (Misc queries) 0 January 24th 05 08:06 PM


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