Thread: parentheses
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Sandy Mann
 
Posts: n/a
Default parentheses

Brendy,

joeu2004 indicated how parentheses are used to change the order of
calculation. In Excel the order that calculations are carried out is not
from left to right but it first of all raises numbers to a power, then
multiplies and divides then finally adds and subtracts *REGARDLESS* of what
order they are laid out in. (Check Help for information on the order of
calculation)

For instance with 1,2 & 3 in A1:A3 respectively if you wanted to add all
three together, multiply the answer by 5, add two to the result and then
multiply the whole answer by 3 and you used the formula:

=A1+A2+A3*5+2*3

it would return a wrong answer (24) because it would first of all multiply
A3 by 5 and 2 by 3, add them together and then add A1 & A2 which is not what
we wanted.

To make sure that it added A1, A2 & A3 together first we have to enclose
them in parentheses:

=(A1+A2+A3)*5+2*3

This will still give a wrong answer because although it will now add A1, A2
& A3 together before it uses the answer in the rest of the formula, it will
also multiply the 2 & 3 together which is not what we want. We therefore
have to add another set of parentheses:

=((A1+A2+A3)*5+2)*3

this will now return the correct result (96) but you may prefer to make it
more obvious that the 2 is only added after the three cells are added
together and multiplied by 5:

=(((A1+A2+A3)*5)+2)*3

this last set of parentheses is not strictly required and makes no
difference to the formula result but I am just using it for this
illustration. We thus have a formula starting off with three parentheses.
QED

When I first started writing formulas I would sometimes join up the top and
bottom ends of the parentheses to make oval shapes. Starting from the inner
most set you should end up with sets of ovals that never cross over one
another. If they ever do cross then you have a mistake somewhere.

--
HTH

Sandy

with @tiscali.co.uk
"Brendy" wrote in message
oups.com...
Thanks for your reply what a mean is when writing formulas that use
different functions and are nested, in what order should I use to put
these ( )

Eg =sum(a1:a4) I can understand but sometimes when creating a
formula 2 (( or 3((( are after the first function in the formula. what
I want to know is there a simplier way of knowing if these double or
treble parentheses should be put at the start or end of the formula.
Hope I have explained myself a little better