Good morning
I am downloading via a web query some information from the web, unfortunately the site I want to use puts the predicted high and low into one cell when it comes into Excel, please see below
A) Is there a formula that I can use that can calculate the average of the numbers in each cell without first stripping them out into intermediate cells
or
B) would I have to consider using =LEFT(TRIM(B166),2) to get the first 2 numbers into one cell (although sometimes there is a single number?) and then in another cell return the next number, I guess by using a MID or RIGHT formula that I can probably work out.
(Edit: I can use something like =MID(B166,9,2) but the 9 may be 8 if the the LEFT formula is only for one number and the MID may be for 1 or 2 numbers?)
average 2 numbers in one cell (Excel 2003 SP3)
-
- SilverLounger
- Posts: 1952
- Joined: 26 Jan 2010, 12:46
- Location: Nr. Heathrow Airport
average 2 numbers in one cell (Excel 2003 SP3)
You do not have the required permissions to view the files attached to this post.
Steve
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin
-
- Administrator
- Posts: 78532
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: average 2 numbers in one cell (Excel 2003 SP3)
Here is a formula that will work regardless of the number of digits in the temperatures. With the two temperatures in A1:
=AVERAGE(--LEFT(A1,FIND("°",A1)-1),--MID(A1,FIND("|",A1)+2,FIND("°",A1,FIND("|",A1)+1)-FIND("|",A1)-2))
=AVERAGE(--LEFT(A1,FIND("°",A1)-1),--MID(A1,FIND("|",A1)+2,FIND("°",A1,FIND("|",A1)+1)-FIND("|",A1)-2))
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78532
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: average 2 numbers in one cell (Excel 2003 SP3)
In case you're interested, here is a workbook that shows the intermediate steps that I used to create the mega-formula from my previous reply.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 12612
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: average 2 numbers in one cell (Excel 2003 SP3)
Thank you for sharing the method, it is a great learning aid.HansV wrote:In case you're interested, here is a workbook that shows the intermediate steps that I used to create the mega-formula from my previous reply...
What is the purpose of the -- in front of some of the formulae?
StuartR
-
- Administrator
- Posts: 78532
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: average 2 numbers in one cell (Excel 2003 SP3)
The -- could actually be omitted here, but it serves to turn a string value into a number. The result of LEFT(...) or MID(...) is a string. The - operator turns the string into a number, and the second - corrects the sign.
Example: LEFT(...) results in the string "23".
-LEFT(...) is the number -23.
--LEFT(...) is the number 23.
However, AVERAGE is clever enough to handle string arguments, so as mentioned, the -- aren't strictly necessary here.
Example: LEFT(...) results in the string "23".
-LEFT(...) is the number -23.
--LEFT(...) is the number 23.
However, AVERAGE is clever enough to handle string arguments, so as mentioned, the -- aren't strictly necessary here.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1952
- Joined: 26 Jan 2010, 12:46
- Location: Nr. Heathrow Airport
Re: average 2 numbers in one cell (Excel 2003 SP3)
Hi HansHansV wrote:Here is a formula that will work regardless of the number of digits in the temperatures. With the two temperatures in A1:
=AVERAGE(--LEFT(A1,FIND("°",A1)-1),--MID(A1,FIND("|",A1)+2,FIND("°",A1,FIND("|",A1)+1)-FIND("|",A1)-2))
That is amazing, thank you very much, also thanks for the explanation which amazingly I can understand (except the -- which you have explained but I am trying to fully digest). I was playing with VALUE etc. and would still be at that stage in a month of Sunday's
Steve
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin
-
- SilverLounger
- Posts: 1952
- Joined: 26 Jan 2010, 12:46
- Location: Nr. Heathrow Airport
Re: average 2 numbers in one cell (Excel 2003 SP3)
Hi HansHansV wrote:Here is a formula that will work regardless of the number of digits in the temperatures. With the two temperatures in A1:
=AVERAGE(--LEFT(A1,FIND("°",A1)-1),--MID(A1,FIND("|",A1)+2,FIND("°",A1,FIND("|",A1)+1)-FIND("|",A1)-2))
I have been trying to follow the steps of your mega formula breakdown with little (make that no) success, so I have tried to amend the above formula to do what I want.
The circumstances are slightly different in that the cells contain this type of format 85°F 29°C / 68°F 20°C and what I need is the average of the °C temperatures so I have amended the formula to
=AVERAGE(--LEFT(M2,FIND("°C",M2)-1),--MID(M2,FIND("/",M2)+2,FIND("°C",M2,FIND("/",M2)+1)-FIND("/",M2)-2))
but I get a #Value! error
Steve
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin
-
- Administrator
- Posts: 78532
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: average 2 numbers in one cell (Excel 2003 SP3)
The formula becomes quite long (this is for a text value in A2):
=AVERAGE(--MID(A2,FIND("°F",A2)+3,FIND("°C",A2)-FIND("°F",A2)-3), --MID(A2,FIND("°F",A2,FIND("°C",A2)+2)+3, FIND("°C",A2,FIND("°C",A2)+2)-FIND("°F",A2, FIND("°C",A2)+2)-3))
I have attached a workbook with the intermediate steps.
=AVERAGE(--MID(A2,FIND("°F",A2)+3,FIND("°C",A2)-FIND("°F",A2)-3), --MID(A2,FIND("°F",A2,FIND("°C",A2)+2)+3, FIND("°C",A2,FIND("°C",A2)+2)-FIND("°F",A2, FIND("°C",A2)+2)-3))
I have attached a workbook with the intermediate steps.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1952
- Joined: 26 Jan 2010, 12:46
- Location: Nr. Heathrow Airport
Re: average 2 numbers in one cell (Excel 2003 SP3)
Absolutely awesomeHansV wrote:The formula becomes quite long (this is for a text value in A2):
=AVERAGE(--MID(A2,FIND("°F",A2)+3,FIND("°C",A2)-FIND("°F",A2)-3), --MID(A2,FIND("°F",A2,FIND("°C",A2)+2)+3, FIND("°C",A2,FIND("°C",A2)+2)-FIND("°F",A2, FIND("°C",A2)+2)-3))
Thank you very much indeed Hans
Steve
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin