Easy question??

JaredMcCullough

Well-known Member
Joined
Aug 1, 2011
Messages
516
I just have a general problem i am trying to simplify my spreadsheet by making corresponding rectangles lets say cell A1 contains two values one a high and one a low (11,12) is it possible for me to average these two numbers and have that average in C1. To continue then B1 would be (15,16). And i would want D1 to be the average of these numbers.
A2 would be (11,22) and I want C2 to be the average of these two. It may be something simple but i have become completely dumbfounded by it thanks
 
Perhaps you would find a UDF (user defined function) more useful...
Code:
Function Avg(CommaDelimitedString As String) As Double
  Avg = Evaluate("=AVERAGE(" & CommaDelimitedString & ")")
End Function

The above UDF will allow you to use this formula on your worksheet...

=Avg(A1)

If you are not familiar with installing UDFs, it is quite simple. Press ALT+F11 to go into the VB editor and, once there, click on Insert/Module from its menu bar, then copy/paste the code I posted above into the code window that just opened up. That's it. You can now use the function in the way I just indicated.
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Thank you very much is this UDF going to work for every instance and the one command statement worked perfectly but it was long and detailed this UDF is a lot easier but will it work for all scenarios related to this problem
 
Upvote 0
Thank you very much is this UDF going to work for every instance and the one command statement worked perfectly but it was long and detailed this UDF is a lot easier but will it work for all scenarios related to this problem

Why don't you try it out and see?


Yes, they should work for all occurances.
The 1 requirement is that the numbers are seperated by a comma.

It will also do any number of numbers, and any length of numbers.
 
Upvote 0
The UDF is not seeming to work with three digit numbers lets say 82,117 it works with two digit numbers like 52,54 any one have any clue what the problem is and how to fix it
 
Upvote 0
This works for me, 99.5 is the result.
Please try again to see there is no typo or other mistake.
 
Upvote 0
I see the issue...

Wigi's works, but Ricks doesn't.

With the combination 82,117
Rick's code is seeing the Comma as a thousands seperator.
Therefore it sees it as the number 82 Thousand 1 Hundred 17


Wigi's uses the Range().Text - makes it a string instead of a number.
 
Upvote 0
The UDF is not seeming to work with three digit numbers lets say 82,117 it works with two digit numbers like 52,54 any one have any clue what the problem is and how to fix it
My guess is you are testing the UDFs against cells that are fomatted as General. Your cells must be formatted as Text, otherwise 82,117 becomes the single number 82117 and not the "number" entry you think it is. My UDFs works fine if the input is a comma separated text value.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top