N
NewsOfTheDay
Hi,
I would like to find a way to search through an experimental list of car
registration, which is alphanumeric. What I want to do is use VBA to find
the registration number using only part of the registration plate number
which will be inputted by the user into an input message box.
I have got an Input Box in place for the user to enter the partial
registration plate number. I want excel to find the cell location from the
list that hold the fully matching registration number, and once it's found
it, to then fill the cell with the colour it green. I'm not sure where to
put this line
If myCell Like ("*" & junk & "*") Then
Here is the full code below;
Sub getValidVehicle()
Dim thisReg As Variant
Dim myCell As Object
Dim Vehicle_Reg As Object
Dim isfound As Boolean
Dim junk As Object 'fragment of registration holder
Worksheets("Sheet1").Select
isfound = False
Do Until isfound
thisReg = InputBox(Prompt:="enter registration")
For Each myCell In Range("Vehicle_Reg")
If myCell Like ("*" & junk & "*") Then 'found it
myCell.Interior.ColorIndex = 10
isfound = True
MsgBox "found at" & myCell.Address
End If
Next
Loop
End Sub
(thank you) Terry
I would like to find a way to search through an experimental list of car
registration, which is alphanumeric. What I want to do is use VBA to find
the registration number using only part of the registration plate number
which will be inputted by the user into an input message box.
I have got an Input Box in place for the user to enter the partial
registration plate number. I want excel to find the cell location from the
list that hold the fully matching registration number, and once it's found
it, to then fill the cell with the colour it green. I'm not sure where to
put this line
If myCell Like ("*" & junk & "*") Then
Here is the full code below;
Sub getValidVehicle()
Dim thisReg As Variant
Dim myCell As Object
Dim Vehicle_Reg As Object
Dim isfound As Boolean
Dim junk As Object 'fragment of registration holder
Worksheets("Sheet1").Select
isfound = False
Do Until isfound
thisReg = InputBox(Prompt:="enter registration")
For Each myCell In Range("Vehicle_Reg")
If myCell Like ("*" & junk & "*") Then 'found it
myCell.Interior.ColorIndex = 10
isfound = True
MsgBox "found at" & myCell.Address
End If
Next
Loop
End Sub
(thank you) Terry