View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Fredg Fredg is offline
external usenet poster
 
Posts: 1
Default Find number of spaces in a string (instr)


I was able to do it in a *very* crude way. I used the MID function t
get each number in the cell. The +0 converts the extracted number bac
to number format as the MID function makes it text.

Maybe someone will see this mess and write a nice VBA function tha
reads each number into an Array and then adds them together. I trie
but I lack the skills.

Here is the non programmer way:

For instance:

Cell A1 = 15449 Cell B1 = 47165

Cell C1:
= (MID(A1,1,1))+0 + (MID(A1,2,1))+0 + (MID(A1,3,1))+0 + (MID(A1,4,1)
+0 +(MID(A1,5,1))+0

Cell D1:
=(MID(B1,1,1))+0 + (MID(B1,2,1))+0 + (MID(B1,3,1))+0 + (MID(B1,4,1)
+0 +(MID(B1,5,1))+0

Cell E1:
=AVERAGE(C1,D1)

Highlight C1, D1 and E1 and then drag down (assuming that you hav
other values in columns A and B).

Of course if you numbers vary in length you will have more work to do.

---
You could combine all this into one cell to acomplish what you asked
for: "=(1+5+4+4+9)/(4+7+1+6+5)" which is not the same as averaging th
two.

Cell C1:

=((MID(A1,1,1))+0 + (MID(A1,2,1))+0 + (MID(A1,3,1))+0 + (MID(A1,4,1)
+0 +(MID(A1,5,1))+0) / ((MID(B1,1,1))+0 + (MID(B1,2,1))+0
(MID(B1,3,1))+0 + (MID(B1,4,1)) +0 +(MID(B1,5,1))+0)


Fre

--
Fred
-----------------------------------------------------------------------
Fredg's Profile: http://www.excelforum.com/member.php...fo&userid=2632
View this thread: http://www.excelforum.com/showthread.php?threadid=46688