Link to home
Start Free TrialLog in
Avatar of angelfromabove
angelfromaboveFlag for United States of America

asked on

Proper way to add an "or" expression in VBA

Hello,  Please see the expression below:originally it read as follows:
If Trim(Cell) = "41 Rank" ,Then
            Cell.Offset(0, 57)

However, I'd like to add another variable to the expression so it performs the same actiona if the cell reads "41 Rank" or "42 Rank".  I tried just adding the word "or" as it's written below, but the macro didn't work. I would appreciate any assistance you can offer.

If Trim(Cell) = "41 Rank" or "42 Rank" ,Then
            Cell.Offset(0, 57)
ASKER CERTIFIED SOLUTION
Avatar of Carlos Ramirez
Carlos Ramirez
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of angelfromabove

ASKER

Thank you, do I need the underscores? and do I also need a comma before Then?
comma is not needed - the underscores are just "line continuation" characters (preceeding space is required), makes code a little easier to read on multiple lines rather then on a single line.

Thanks
Got it thank you very much, it worked!
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.