VBA IF statement not working.....

lukeshuttlewood

Board Regular
Joined
Jul 27, 2004
Messages
90
When i try to run the IF below i get this error, any ideas why?

Run time error 13
Type Mismatch


If Originator Or ProposedActionee Or Approval1 Or Approval2 Or Approval3 Or Approval4 Or Approval5 Or Approval6 = UserNames Then

All the variables are as type string. Basically each of these variables are peoples names eg "LUKE.SHUTTLEWOOD". If "LUKE.SHUTTLEWOOD" is equal to the UserNames variable then do X else do Y.

I dont know why i get type mismatch when all variables are string??!!
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
You have to repeat the equality test for each variable, eg:

If Originator = UserNames Or ProposedActionee = UserNames Or Approval1 = UserNames Or Approval2 = UserNames Or Approval3 = UserNames Or Approval4 = UserNames Or Approval5 = UserNames Or Approval6 = UserNames Then
 

Watch MrExcel Video

Forum statistics

Threads
1,118,670
Messages
5,573,569
Members
412,537
Latest member
Mohamed_5966
Top