E
excelnut1954
The code below performs a search of PO# based on user input. However,
there are cases where the PO# will have a letter after it. Ex: M123456
might end up being on list as M1234156A, or .M123456B, etc The search
below will not find that record unless user types in the A at the end.
These PO#s will be different forms and lengths, but they will always
end in numbers, unless they have that trailing letter. It could be
AIR090606, or AIR090606A.
Is there a way to address these possible trailing letters so my Find
macro will include them?
Thanks big time for all the help I've received here since I started
VBA last year.
J.O.
'Declarations
Public rngToSearch As Range
Public rngFound As Range
Public strFirst As String
Public FindPOVal As String
Public FindWOVal As String
Sub FindViaPOCurrent()
'This is for the PO/PL search via UserForm12. Clicking the OK button
'brings you here. If record found, it opens up UserForm13 to show
'that record. The "Find Another Record" button will also loop back
here.
'Names the PO column w/ this Dim name
Dim PO_Column As Range
Worksheets("Official List").Activate
Set rngToSearch = Sheets("Official List").Range("POCurrent_Column")
Set rngFound = rngToSearch.Find(What:=FindPOVal, _
LookIn:=xlValues, _
LookAt:=xlWhole)
If rngFound Is Nothing Then
Unload UserForm12
'Will ask if you want to search Deleted List w/ this same #.
UserForm7.Show
Else
strFirst = rngFound.Address
rngFound.Select
Unload UserForm12
UserForm13.Show
End If
End Sub
there are cases where the PO# will have a letter after it. Ex: M123456
might end up being on list as M1234156A, or .M123456B, etc The search
below will not find that record unless user types in the A at the end.
These PO#s will be different forms and lengths, but they will always
end in numbers, unless they have that trailing letter. It could be
AIR090606, or AIR090606A.
Is there a way to address these possible trailing letters so my Find
macro will include them?
Thanks big time for all the help I've received here since I started
VBA last year.
J.O.
'Declarations
Public rngToSearch As Range
Public rngFound As Range
Public strFirst As String
Public FindPOVal As String
Public FindWOVal As String
Sub FindViaPOCurrent()
'This is for the PO/PL search via UserForm12. Clicking the OK button
'brings you here. If record found, it opens up UserForm13 to show
'that record. The "Find Another Record" button will also loop back
here.
'Names the PO column w/ this Dim name
Dim PO_Column As Range
Worksheets("Official List").Activate
Set rngToSearch = Sheets("Official List").Range("POCurrent_Column")
Set rngFound = rngToSearch.Find(What:=FindPOVal, _
LookIn:=xlValues, _
LookAt:=xlWhole)
If rngFound Is Nothing Then
Unload UserForm12
'Will ask if you want to search Deleted List w/ this same #.
UserForm7.Show
Else
strFirst = rngFound.Address
rngFound.Select
Unload UserForm12
UserForm13.Show
End If
End Sub