Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can VBA code be used to return the average of a worksheet selection? I'd
like to code a userform textbox to return this average. D.S. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way:
UserForm1.TextBox1.Text = Application.Average(Range("A1:A100")) In article , "D.S." wrote: Can VBA code be used to return the average of a worksheet selection? I'd like to code a userform textbox to return this average. D.S. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, but that's still not what I'm looking for, that would return the
average of the same range each time. I'm trying to return the average of the range I have selected with my mouse at the time the userform is loaded. D.S. "J.E. McGimpsey" wrote in message ... One way: UserForm1.TextBox1.Text = Application.Average(Range("A1:A100")) In article , "D.S." wrote: Can VBA code be used to return the average of a worksheet selection? I'd like to code a userform textbox to return this average. D.S. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
one way:
With UserForm1 On Error Resume Next .TextBox1.Text = Application.Average(Selection) If Err Then _ .TextBox1.Text = "Invalid Selection" 'or perhaps zero On Error GoTo 0 .Show End With In article , "D.S." wrote: Thanks, but that's still not what I'm looking for, that would return the average of the same range each time. I'm trying to return the average of the range I have selected with my mouse at the time the userform is loaded. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, that did help me get going in the right direction.
What seems to be working is ..TextBox1.Text=Application.Worksheetfunction.Aver age(Selection) D.S. "J.E. McGimpsey" wrote in message ... one way: With UserForm1 On Error Resume Next .TextBox1.Text = Application.Average(Selection) If Err Then _ .TextBox1.Text = "Invalid Selection" 'or perhaps zero On Error GoTo 0 .Show End With In article , "D.S." wrote: Thanks, but that's still not what I'm looking for, that would return the average of the same range each time. I'm trying to return the average of the range I have selected with my mouse at the time the userform is loaded. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, that did help get me going in the right direction. The code is
almost the same. This does what I'm looking for. ..TextBox1.Text = Application.Worksheetfunction.Average(Selection) Donald "J.E. McGimpsey" wrote in message ... one way: With UserForm1 On Error Resume Next .TextBox1.Text = Application.Average(Selection) If Err Then _ .TextBox1.Text = "Invalid Selection" 'or perhaps zero On Error GoTo 0 .Show End With In article , "D.S." wrote: Thanks, but that's still not what I'm looking for, that would return the average of the same range each time. I'm trying to return the average of the range I have selected with my mouse at the time the userform is loaded. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, but that's still not exactly what I'm looking for. That would
always return the average of a specific range each time the userform is loaded. What I need is to return the average of any range of cells that I may have selected with my mouse at the time the userform is loaded. D.S. "J.E. McGimpsey" wrote in message ... One way: UserForm1.TextBox1.Text = Application.Average(Range("A1:A100")) In article , "D.S." wrote: Can VBA code be used to return the average of a worksheet selection? I'd like to code a userform textbox to return this average. D.S. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe what you are looking for is the 'InputBox' method of the Excel
application class, like this: Set MyRange = Application.InputBox("Select Range", "Select Range", Type:=8) Using Type 8 will return a range object that you can then apply the Average function to. Bill Barclift "D.S." wrote in message ... Thanks, but that's still not exactly what I'm looking for. That would always return the average of a specific range each time the userform is loaded. What I need is to return the average of any range of cells that I may have selected with my mouse at the time the userform is loaded. D.S. "J.E. McGimpsey" wrote in message ... One way: UserForm1.TextBox1.Text = Application.Average(Range("A1:A100")) In article , "D.S." wrote: Can VBA code be used to return the average of a worksheet selection? I'd like to code a userform textbox to return this average. D.S. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
A formula to AVERAGE IF but only average a set number of values | Excel Worksheet Functions | |||
Find monthly average but have average automatically configured | Excel Discussion (Misc queries) | |||
Error Handling #N/A with AVERAGE Function - Average of values in Row | Excel Worksheet Functions | |||
Weighed Average of a weiged average when there are blanks | Excel Discussion (Misc queries) | |||
how does one convert text to a formula "average(A:A)" to =average( | Excel Worksheet Functions |