fomula to divide

R

Ranjith Kurian

in cell A1 i hv typed the amounts as follows CellA1=37020+400+2676.8+247009.68
and in cell A2 the rates typed are as follows =7.7519+1+49.3945+1
now i need my CellA2 rates to be divide with CellA1 amounts as per arranged
example

RESULT
37020/7.7519 + 400/1 + 2676.8/49.3945 + 247009.68/1
and the expected result is252239.4757

Is there any formula to dividethe CellA1/CellA2 as per the arranged orders,
with out any manually work
 
B

Bernd P

Hello,

I suggest to use this UDF:
Function cellsumdivision(r1 As Range, r2 As Range) As Double
Dim v1, v2
Dim i As Long, d As Double
With Application.WorksheetFunction
v1 = Split(Mid(r1.Formula, 2, 2048), "+")
v2 = Split(Mid(r2.Formula, 2, 2048), "+")
If UBound(v1) = UBound(v2) Then
For i = LBound(v2) To UBound(v2)
d = d + v1(i) / v2(i)
Next i
cellsumdivision = d
Else
cellsumdivision = CVErr(xlErrValue)
End If
End With
End Function

Press ALT + F11, insert a new macro module, copy macro code into it,
go back to worksheet and then use
=cellsumdivision(A1,A2)

Regards,
Bernd
 
N

Neil M

Could you not simply use the mathematical order of operations in conjunction
with brackets to tell what you wanted to divide first?
If I wanted to divide 20 by 2 then it would simply be =20/2

If I wanted to divide that by 2 again after the first function it would be
=(20/2)/2

I think that would work, wouldnt it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top