ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Average of range help (https://www.excelbanter.com/excel-programming/370710-average-range-help.html)

impius1

Average of range help
 

Hello...I'm sure this is easy but i am new to macros...

I am trying to prompt a user with an input box where they will select a
range of values. Those values would then be averaged and placed in a
cell or a msgbox.


Thanks in advance for your help!


--
impius1
------------------------------------------------------------------------
impius1's Profile: http://www.excelforum.com/member.php...o&userid=37671
View this thread: http://www.excelforum.com/showthread...hreadid=572778


impius1[_2_]

Average of range help
 

Cant be Done?


--
impius1
------------------------------------------------------------------------
impius1's Profile: http://www.excelforum.com/member.php...o&userid=37671
View this thread: http://www.excelforum.com/showthread...hreadid=572778


Bernie Deitrick

Average of range help
 
impius,

Sub DoAverage()
Dim myAvg As Double
On Error Resume Next
myAvg = Application.Average(Application.InputBox( _
"Select the range to average", , , , , , , 8))
MsgBox myAvg
Range("A1").Value = myAvg
End Sub


HTH,
Bernie
MS Excel MVP


"impius1" wrote in message
...

Hello...I'm sure this is easy but i am new to macros...

I am trying to prompt a user with an input box where they will select a
range of values. Those values would then be averaged and placed in a
cell or a msgbox.


Thanks in advance for your help!


--
impius1
------------------------------------------------------------------------
impius1's Profile: http://www.excelforum.com/member.php...o&userid=37671
View this thread: http://www.excelforum.com/showthread...hreadid=572778




impius1[_3_]

Average of range help
 

Thanks! One more question that may make this quite a bit mor
difficult.

If the user selects a range such as a1:c5, I would like to sum column
of the selected range, then sum column c of the selected range...The
divide the result of the sum of c by the result of sum of b, and the
display final result.

I dont know if that is even possible but thanks for your time

--
impius
-----------------------------------------------------------------------
impius1's Profile: http://www.excelforum.com/member.php...fo&userid=3767
View this thread: http://www.excelforum.com/showthread.php?threadid=57277


Bernie Deitrick

Average of range help
 
Sub DoAverageV2()
Dim myAvg As Double
Dim myR As Range
On Error Resume Next
Set myR = Application.InputBox( _
"Select the range to average", , , , , , , 8)
If myR.Columns.Count < 3 Then Exit Sub
myAvg = Application.Sum(myR.Columns(3)) / _
Application.Sum(myR.Columns(2))
MsgBox myAvg
Range("A1").Value = myAvg
End Sub

HTH,
Bernie
MS Excel MVP


"impius1" wrote in message
...

Thanks! One more question that may make this quite a bit more
difficult.

If the user selects a range such as a1:c5, I would like to sum column b
of the selected range, then sum column c of the selected range...Then
divide the result of the sum of c by the result of sum of b, and then
display final result.

I dont know if that is even possible but thanks for your time!


--
impius1
------------------------------------------------------------------------
impius1's Profile: http://www.excelforum.com/member.php...o&userid=37671
View this thread: http://www.excelforum.com/showthread...hreadid=572778




impius1[_4_]

Average of range help
 

Thanks so much!


--
impius1
------------------------------------------------------------------------
impius1's Profile: http://www.excelforum.com/member.php...o&userid=37671
View this thread: http://www.excelforum.com/showthread...hreadid=572778


Bernie Deitrick

Average of range help
 
You're welcome!

Bernie
MS Excel MVP

Thanks so much!





All times are GMT +1. The time now is 10:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com