View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
smartin smartin is offline
external usenet poster
 
Posts: 915
Default Wildcards in a case statement

DG wrote:
I have a column that contains a 2 character code. How can I use only one
case statement to be true for all cases where the cell started with a C?
For example the cell could contain CA, CD, CQ, C5 etc.

Select Case Cells(x,9)
Case "BQ"
Rejected = False
Case "C*"
Rejected = True
End Select

Dan



You can do it like this:

Select Case Cells(x,9)
Case "BQ"
Rejected = False
Case Else
If Cells(x,9) Like "C*" Then
Rejected = True
End If
End Select

Of course, if you are only testing two conditions you don't really need
Select Case.