PC Review


Reply
Thread Tools Rate Thread

Calculating an average using VBA

 
 
=?Utf-8?B?QmVu?=
Guest
Posts: n/a
 
      2nd Aug 2007
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 With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      2nd Aug 2007
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

 
Reply With Quote
 
=?Utf-8?B?QmVu?=
Guest
Posts: n/a
 
      2nd Aug 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Calculating the Average Stefan Hoffmann Microsoft Access Reports 0 22nd Mar 2009 11:27 AM
Calculating Average ub Microsoft Excel Misc 2 16th Jul 2008 05:14 PM
Calculating average of average Lars Brownie Microsoft Access 3 18th Apr 2008 07:36 PM
Calculating the average =?Utf-8?B?QW5keV9Ucm93?= Microsoft Excel Misc 3 27th Jul 2007 02:15 PM
calculating average =?Utf-8?B?UGF0dGlQ?= Microsoft Access Reports 2 5th Aug 2005 01:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:46 PM.