Quick question
Carlos,
I would suggest you try to make the syntax as realistic as possible. As Tom
says, what you have written would clearly run into problems. Also, it is hard
to tell (for me at least) whether you are talking about writing the code as a
worksheet function or within a VBA module
If you are working in a VBA module then you can perform multiple tasks based
on the results of your comparison:
If (A1 = B1) And (B1=C1) Then
Do this
Do this too
And this
ElseIf (A1 = B2)
Do this
And this
Else
Do this
End If
If you are working with worksheet formulas then no, because you have:
=IF(AND(A1=B1,B1=C1), C2, C3)
So the cell you type the formula in will result in the value of C2 if the
condition is true, and C3 if the condition is false.
A worksheet function doesnt (as far as Im aware) allow you to alter
another cell directly, it simply gives the result of the formula you type in
that cell.
However, if you type
=IF(AND(A1=B1,B1=C1),C2=5,C3=4))
Then if A1 = B1 and B1 = C1 then the true part of the result is looked at
(C2=5) and if cell C2 does equal 5 the cell containing the formula will
result in €śTrue€ť, whereas if cell C2 does not equal 5 then the cell
containing the formula will result in €śFalse€ť. Also, if the original
condition is False, then C3 = 4 is compared and the cell containing the
formula will again result in either True or False. Therefore, there are
numerous ways of getting the same result, and for most purposes you will not
know whether conditions have been met or not (or which conditions at least).
It would probably be better to keep all the conditional statements in the 1st
part of the function. Anyway, I dont believe this is what you are trying to
attempt, but I thought Id let you know, just so you can avoid this situation.
" wrote:
for an If..Then statement you can do If "A1=B1" and "B1=C1" then
A1=C1. But is there a connecting word(AND) that can be done in the
then part. such as......If (A1=B1) and (B1=C1) then (A1=C1) And
(A1+3=D1)
I know the syntacs aren't correct its an example to get the point
across. Thanks
|