Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Quick question

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Quick question

If A1=B1 and B1=C1 then
A1=C1
D1 = A1+3
End if

A1 + 3 can't equal D1 unless you are testing if they do?

--
Regards,
Tom Ogilvy


" 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Quick question



" 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Quick question

There is no reason to do an assignment of A1=C1 since by logic this is
already true. So I think we need a better explanation of what they
are trying to accomplish.

Peter Richardson

On Jul 23, 3:22 pm, Tom Ogilvy
wrote:
If A1=B1 and B1=C1 then
A1=C1
D1 = A1+3
End if

A1 + 3 can't equal D1 unless you are testing if they do?

--
Regards,
Tom Ogilvy



" 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- Hide quoted text -


- Show quoted text -



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
quick question riggi Excel Discussion (Misc queries) 4 January 31st 07 06:11 AM
quick question tmela Excel Discussion (Misc queries) 2 August 19th 06 02:56 AM
Quick question - quick answer about assigning shortcut keys funkymonkUK[_75_] Excel Programming 1 October 13th 05 10:50 AM
Very Quick Question Chuckles123[_70_] Excel Programming 0 November 18th 04 07:11 PM
Very Quick Question Chuckles123[_69_] Excel Programming 1 November 18th 04 05:49 PM


All times are GMT +1. The time now is 01:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"