Hi,
I'm getting a 'Runtime error 13 - Type mismatch' when executing this line.
I can't figure out what's wrong with it. Could anyone help?
Please Login or Register to view this content.
Hi,
I'm getting a 'Runtime error 13 - Type mismatch' when executing this line.
I can't figure out what's wrong with it. Could anyone help?
Please Login or Register to view this content.
You have to repeat the var comparison, and I think you meant And not Or:
Please Login or Register to view this content.
Rory
Please Login or Register to view this content.
Last edited by AlphaFrog; 11-19-2019 at 08:54 AM.
Surround your VBA code with CODE tags e.g.;
[CODE]your VBA code here[/CODE]
The # button in the forum editor will apply CODE tags around your selected text.
Guessing you can't have/refer to a whole column value.
And you'd need to change the Or to And and repeat the "var <>"
Trevor Shuttleworth - Retired Excel/VBA Consultant
I dream of a better world where chickens can cross the road without having their motives questioned
'Being unapologetic means never having to say you're sorry' John Cooper Clarke
I assumed those were named ranges?
AlphaFrog,
I tried the parentheses and still get the error. Could it be something else?
rorya,
It is OR. Those two outputs are valid independently.
An Or condition would always be true, since if it matches one it won't match the other. Did you try it?
Tried And instead of Or and still get the error.
If I remove the second condition it works, so I guess it has something to do with the syntax.
What was the exact code you tried with the And in place?
Also, please confirm that SN and FN are named ranges, and that none of the cells being referred to contain error values.
The code I tried is the same. I only replaced OR for AND just to see if it throws an error.
SN and FN are cell labels. They don't contain errors. The code works if I remove everything after OR.
I read your first reply again and you suggested to repeat the var comparison. Why is that? Shouldn't it work using Or/And instead?
Rorya, I did just that. What you suggested. I repeated the var comparison instead or putting everything on the same line and it works.
Thanks for your help!
The Or is an operator that works on the expressions either side of it, which need to evaluate to Boolean types. So:
is valid since the two expressions either side will be either True or False, but if you write this:Please Login or Register to view this content.
the evaluation steps will be:Please Login or Register to view this content.
which will be either True or False, then:Please Login or Register to view this content.
which makes no sense, hence the error.Please Login or Register to view this content.
Excellent explanation. I get it now.
Thank you rorya!
Glad to help.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks