Ehudz
Ehudz

Reputation: 633

String Comparison with Array Item and String with VBA in Excel

This is probably a simple one, but I can't seem to find out what's wrong:

if temp_array(1) = temp_string2 & temp_array(2) = "w" then
....
end if

the values are:

temp_array(1) = "test1"

temp_string2 = "test2"

temp_array(2) = "w"

I get a type mismatch error highlighting the conditional comparisons...

Upvotes: 0

Views: 1243

Answers (1)

GSerg
GSerg

Reputation: 78183

& is string concatenation, not logical and.

if temp_array(1) = temp_string2 And temp_array(2) = "w" then 

Upvotes: 3

Related Questions