Code:
'/////////////////////////////Variable Declaration//////////////////////////////////////////////////
Dim masterData As Worksheet, console As Worksheet, inputCell As Range, firstNames As Range, lastName As Range, countWhichName As Range 'EZ refs for sheets/ranges
Dim client As String, searchInput As String 'text variable for client and for search value
Dim matchCountLast As Integer
Dim matchCountFirst As Integer
Dim inputBoxValue As Variant
'/////////////////////////////////////Constants set//////////////////////////////////////////////////
Set masterData = Sheets("Master Data")
Set console = Sheets("Client Console")
Set firstName = masterData.Range("C2:C99999")
Set lastName = masterData.Range("B2:B99999")
Set inputCell = console.Range("E3") 'setting variable equal to cell that pulls name
'///////////////////////////////////// For USERFORMS //////////////////////////////////////////////////////////////
Dim recordType As String, firstRecord As String, lastRecord As String
'////////////////////////////// Section for finding and pulling client info ///////////////////////////////////////
searchInput = inputCell.Value
client = lastName.Find(What:=searchInput, MatchCase:=False) 'this statement is killing me
If client <> "" Then
matchCountLast = Application.WorksheetFunction.CountIf(lastName, client)
matchCountFirst = Application.WorksheetFunction.CountIf(firstName, client)
End If
Basically my problem is with the line last before the if statement. Sometimes the find will find nothing. I intend it to be that way. I don't wanna use on error resume next without understanding how to properly handle the error.
Little overview, this is personal worksheet I am going to use for storing, entering, and pulling data for potential clients, leads, prospects, etc. Basically it is going to check if the name matches any lasts, then if it matches any firsts. I have the program down for most of it. However I can't figure out how to manuever around this error. Hopefully it isnt syntax bc ive been trying to figure it out for like 24 hours now
Also, if i used .firstName range instead of .lastName. I wouldn't get an error. The fact is i'm testing it. I entered a first name and I want it to check last names first then check first names.
Thanks for your help