VBA syntax error If a string variable is "a" or "b" or "c",

I am trying to write code that does the following in VBA, but I get an error: Type of mismatch

Quark is a string variable

If quark = "F" Or "DE" Or "ED" Then 
+6
source share
3 answers

Each "OR" is its own logical expression.

 If quark = "F" Or quark ="DE" Or quark ="ED" Then 

You could achieve what you are trying to do with the case, although I think

 Select Case quark Case "F","DE","ED" stuffHere end select 

EDIT: I see that you are getting a type mismatch, are you a dull quark like a string?

 dim quark as string 
+5
source

You can try to compare like this: -

 If quark = "F" Or quark = "DE" Or quark = "ED" Then 

instead of: -

 If quark = "F" Or "DE" Or "ED" Then 
+2
source

You need to compare the quark with the rows.

 If quark = "F" Or quark = "DE" Or quark = "ED" Then 
+1
source

Source: https://habr.com/ru/post/954019/


All Articles