Wildcards in a text string

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I need to identify a 12 character alpha/numeric text strings. (AAA0853J2315) for example. I have my Macro that I know works, but I'm trying to use just the first three alphanumeric characters since those will never change. I've tried "AAA", "AAA*********", "AAA#########", and few others. Thank you,

VBA Code:
Sub Foreign_ACFT()
    Dim i As Long
    For i = 1 To ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
        Select Case ActiveSheet.Cells(i, 1).Value
            Case "UAF*********", "RRR*********", "IFC*********"
                ActiveSheet.Range("F" & i) = "Check Port of Entry Requirements"
        End Select
    Next i

End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
If the characters you are checking are always the 1st 3, use
VBA Code:
Select Case left(ActiveSheet.Cells(i, 1).Value,3)
            Case "UAF", "RRR", "IFC"
 
Upvote 0
Solution
If the characters you are checking are always the 1st 3, use
VBA Code:
Select Case left(ActiveSheet.Cells(i, 1).Value,3)
            Case "UAF", "RRR", "IFC"
Bingo- perfect thank you!
 
Upvote 0
How about
VBA Code:
Sub Foreign_ACFT()
    Dim i As Long, ans As String
    For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
        If Left(Cells(i, 1).Value, 3) = "UAF" Or Left(Cells(i, 1).Value, 3) = "RRR" Or Left(Cells(i, 1).Value, 3) = "IFC" Then
            Range("F" & i) = "Check Port of Entry Requirements"
        End If
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,016
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top