Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

if statment

  Asked By: James    Date: Nov 18    Category: MS Office    Views: 651
  

So is there way to do an and statement in an if statement?

such as:

ActiveCell.FormulaR1C1 = IF(RC[-1]=R[1]C[-1] AND
RC[-2]=R[1]C[-2],""duplicate"","" "")"

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Jenny Lopez     Answered On: Nov 18

Yes,



If "Test Condition" = True And "Test Condition" = True then

Do Something

End If

 
Answer #2    Answered By: Aiko Suzuki     Answered On: Nov 18

You may need to change the statementa s follows:

ActiveCell.FormulaR1C1 =
"=IF(AND(RC[-1]=R[1]C[-1],RC[-2]=R[1]C[-2]),""duplicate"","" "")"

If Active Cell is F4 and run this code, then VBA will output this formula:
=IF(AND(E4=E5,D4=D5),"duplicate"," ")

 
Didn't find what you were looking for? Find more on if statment Or get search suggestion and latest updates.

Related Topics:



Tagged:  

 
 
 

Related Post