Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Navin Gada   on Jan 02 In MS Office Category.

  
Question Answered By: Calandre Bernard   on Jan 02

Although Help says: "Used to perform a logical conjunction on two
expressions." there's nothing to stop you stringing several ANDs together.

To test, I tried the following: Enter 1,2,3,4,5 in cells A1:E1
respectively.
1. This formula in another cell:
=AND(A1=1,B1=2,C1=3,D1=4,E1=5)
returns TRUE
2. In vba:
If Range("A1") = 1 And Range("B1") = 2 And Range("C1") = 3 And
Range("D1") = 4 And Range("E1") = 5 Then MsgBox "True!"
(That's all one line) pops up the message box.
3. If you want to stick with the way the worksheet AND works then also
in vba:
If Application.WorksheetFunction.And(Range("A1") = 1, Range("B1") = 2,
Range("C1") = 3, Range("D1") = 4, Range("E1") = 5) Then MsgBox "True too!"
(Likewise one line) also pops up the message box.

If I changed any value in any of the cells A1:E1,
Item 1 returned FALSE, items 2 and 3 did not pop up a message box.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on AND - Only two expressions Or get search suggestion and latest updates.


Tagged: