Return userform values based on 2 search criteria
Hi all,
I am using the code below through a userform that will populate labels, textboxes, etc with client information based on the client name in column A (i.e. client location, badge #, active status, etc.). Each client has different types of equipment (i.e. batons, handcuffs, etc) and each piece of equipment has a unique serial number for individual clients however there may be a risk that there could be duplicate serial numbers across all clients.
My question is this: Is there a way to add additional criteria to the code below to narrow down search results within the spreadsheet to include client name and serial number? This would ensure that users are able to display the proper equipment for the client.
Thanks in advance!
Dim f As Range
Dim ws As Worksheet
Dim rng As Range
Dim answer As Integer
With SearchClient
Set f = Sheets(“DTT”).Range(“D4:D1503”).Find(.Value, , xlValues, xlWhole, , , False)
If Not f Is Nothing Then
ClientNameModifyProfile.Caption = Sheets(“CLIENT PROFILES”).Range(“C” & f.Row).Value
BadgeModifyProfile.Caption = Sheets(“CLIENT PROFILES”).Range(“E” & f.Row).Value
ActiveOfficerModifyProfile.Caption = Sheets(“CLIENT PROFILES”).Range(“F” & f.Row).Value
ActiveClientGroup.Value = Sheets(“CLIENT PROFILES”).Range(“O” & f.Row).Value
NotesClientProfile.Value = Sheets(“CLIENT PROFILES”).Range(“J” & f.Row).Value
HomePositionClientProfile.Value = Sheets(“CLIENT PROFILES”).Range(“G” & f.Row).Value
HomeUnitClientProfile.Value = Sheets(“CLIENT PROFILES”).Range(“H” & f.Row).Value
HomeLocationClientProfile.Value = Sheets(“CLIENT PROFILES”).Range(“I” & f.Row).Value
TempPositionType.Caption = Sheets(“CLIENT PROFILES”).Range(“K” & f.Row).Value
TempPosition.Caption = Sheets(“CLIENT PROFILES”).Range(“L” & f.Row).Value
TempUnit.Caption = Sheets(“CLIENT PROFILES”).Range(“M” & f.Row).Value
TempLocation.Caption = Sheets(“CLIENT PROFILES”).Range(“N” & f.Row).Value
Else
MsgBox “No Client Profile exists for this individual.”
Exit Sub
End If
End With
Hi all, I am using the code below through a userform that will populate labels, textboxes, etc with client information based on the client name in column A (i.e. client location, badge #, active status, etc.). Each client has different types of equipment (i.e. batons, handcuffs, etc) and each piece of equipment has a unique serial number for individual clients however there may be a risk that there could be duplicate serial numbers across all clients. My question is this: Is there a way to add additional criteria to the code below to narrow down search results within the spreadsheet to include client name and serial number? This would ensure that users are able to display the proper equipment for the client. Thanks in advance! Dim f As Range
Dim ws As Worksheet
Dim rng As Range
Dim answer As Integer
With SearchClient
Set f = Sheets(“DTT”).Range(“D4:D1503”).Find(.Value, , xlValues, xlWhole, , , False)
If Not f Is Nothing Then
ClientNameModifyProfile.Caption = Sheets(“CLIENT PROFILES”).Range(“C” & f.Row).Value
BadgeModifyProfile.Caption = Sheets(“CLIENT PROFILES”).Range(“E” & f.Row).Value
ActiveOfficerModifyProfile.Caption = Sheets(“CLIENT PROFILES”).Range(“F” & f.Row).Value
ActiveClientGroup.Value = Sheets(“CLIENT PROFILES”).Range(“O” & f.Row).Value
NotesClientProfile.Value = Sheets(“CLIENT PROFILES”).Range(“J” & f.Row).Value
HomePositionClientProfile.Value = Sheets(“CLIENT PROFILES”).Range(“G” & f.Row).Value
HomeUnitClientProfile.Value = Sheets(“CLIENT PROFILES”).Range(“H” & f.Row).Value
HomeLocationClientProfile.Value = Sheets(“CLIENT PROFILES”).Range(“I” & f.Row).Value
TempPositionType.Caption = Sheets(“CLIENT PROFILES”).Range(“K” & f.Row).Value
TempPosition.Caption = Sheets(“CLIENT PROFILES”).Range(“L” & f.Row).Value
TempUnit.Caption = Sheets(“CLIENT PROFILES”).Range(“M” & f.Row).Value
TempLocation.Caption = Sheets(“CLIENT PROFILES”).Range(“N” & f.Row).Value
Else
MsgBox “No Client Profile exists for this individual.”
Exit Sub
End If
End With Read More