Wildcards in a text string

Livin404

Active Member
Joined
Jan 7, 2019
Messages
393
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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

tusharm

MrExcel MVP
Joined
May 28, 2002
Messages
11,028
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"
 
Solution

Livin404

Active Member
Joined
Jan 7, 2019
Messages
393
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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!
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,118
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,129,386
Messages
5,636,010
Members
416,892
Latest member
Bensch

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
Top