The idea here is that I can pass the function a value and a range, and then it searches that range for the value, and returns the address of the cell in which the value appears.
But when I put this in the immediate window to test:
I get a type mismatch error. What gives?
Code:
Function Find_Value_Location(FindString As String, Rng As Range)
If Trim(FindString) <> "" Then
With Sheets("Sheet1").Range(Rng)
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
End If
Find_Value_Location = Rng.Cells.Address
End Function
But when I put this in the immediate window to test:
Code:
Call Find_Value_Location("Q1","B:B")
I get a type mismatch error. What gives?