More Efficient IF
I don't consider your If-Then statement to be convoluted at all... it is how
I would write it my own code. If you are looking for something more
"concise", well, you could use either of these...
If InStr("*1*3*7*12*", "*" & Variable & "*") Then
If Variable Like "[137]" Or Variable = 12 Then
but personally, I think you will find them harder to understand 6 months
from now if you have to come back to maintain or modify your code.
Rick
"David" wrote in message
ups.com...
Hello
I've got a convaluted IF statement:
--
If Variable = 1 or Variable = 3 or Variable = 7 or Variable = 12 Then
--
Using other languages you could for example do something like this:
--
If Variable MATCHES (1,3,7,12) Then
--
What would be the best way using VBA? Do you increase the efficiency
of the code by adding brackets etc, as in PICK Basic?
Any other general efficiency tips would be appreciated as I've been
asked to update some complex code that was written a long time ago by
one of my ex-colleagues and is deemed inefficient, but I'm not expert
when it comes to VBA, as you probably noticed!
Thanks!
|