Batterychook
New Member
- Joined
- Jul 16, 2018
- Messages
- 11
New to VBA, so have searched and borrowed code and ideas from anywhere without really understanding yet what's going on.
What is the correct String search syntax to find an exact integer match in a column rather than returning all numbers containing the integer ?
That is, if I search for "3", the search returns 3, but also 13, 23, 30, 33, etc. But, I only want the exact match !
The code below extracts passenger details identified by a unique Pax # entered into an Input Box to enable printing a boarding pass. Unfortunately, it currently returns more than one passenger's details.
This post supercedes a separate but similar problem posted last week
Thanks to all responders from a Newbie
BC
What is the correct String search syntax to find an exact integer match in a column rather than returning all numbers containing the integer ?
That is, if I search for "3", the search returns 3, but also 13, 23, 30, 33, etc. But, I only want the exact match !
The code below extracts passenger details identified by a unique Pax # entered into an Input Box to enable printing a boarding pass. Unfortunately, it currently returns more than one passenger's details.
Code:
Sub Procedure1()
Dim strsearch As String, lastline As Integer, tocopy As Integer
strsearch = CStr(InputBox("enter the Pax # to Print Boarding Pass"))
lastline = Range("C100").End(xlUp).Row
j = 1
For i = 1 To lastline
For Each c In Range("C" & i)
If InStr(c.Text, strsearch) Then
tocopy = 1
End If
Next c
If tocopy = 1 Then
Rows(i).Copy Destination:=Sheets("Boarding Pass").Rows(j)
j = j + 1
End If
tocopy = 0
Next i
End Sub
This post supercedes a separate but similar problem posted last week
Thanks to all responders from a Newbie
BC