1

I am trying evaluate each cell and if the value in A is 01,06,42,66 and the value in B is Outside, then DoStuff.

With the following case statement, it only picks up 66 not the rest. I could write a case statement for each combination, but that would be too much. Do you have any suggestions on how to simplify this?

Select Case .Range("A" & i).Value A & .Range("B" & i).Value 
Case "01","06","42","66" & "Outside" 
    DoStuff
End Select 

1 Answer 1

3

put an if in your Select Case:

Select Case .Range("A" & i).Value    
Case "01","06","42","66"
    If .Range("B" & i).Value = "Outside" Then
        DoStuff
    End If
End Select 

Or you will need to concatenate all choices:

Select Case .Range("A" & i).Value  & .Range("B" & i).Value 
Case "01Outside","06Outside","42Outside","66Outside"
    DoStuff
End Select 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.