I am currently trying to call the function written below, but I am getting a #VALUE error that I simply can't figure out. When I call the function in the sub below, I have no problems and I am able to return the values I am looking for. I am just confused and looking for any advice!! Thanks in advance!!!!
Function findNum(VehName As String, iqsNum As String) As Double
Windows("Numbers Sheet.xlsx").Activate 'activates the sheet where we get data
Dim SCol1 As Integer 'Dimension variables
Dim SRow As Integer
With Range("A3:A999") 'selects the range where we are looking
Set PValue = .find(What:=iqsNum, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False) 'looks for the value
'goes through the sheet and grabs the location of the cell and makes it SRow and SCol
If Not PValue Is Nothing Then
Cell_Split_R = Split(PValue.Address(ReferenceStyle:=xlR1C1), "R")
Cell_Split_C = Split(Cell_Split_R(1), "C")
SRow = Cell_Split_C(0)
SCol = Cell_Split_C(1)
End If
End With
With Range("A3:ZZ3")
Set PValue = .find(What:=VehName, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
If Not PValue Is Nothing Then
Cell_Split_R = Split(PValue.Address(ReferenceStyle:=xlR1C1), "R")
Cell_Split_C = Split(Cell_Split_R(1), "C")
SRow1 = Cell_Split_C(0)
SCol1 = Cell_Split_C(1)
End If
End With
Cells(SRow, SCol1).Select 'selects the cell we're looking at
Cells(3, 30) = Cells(SRow, SCol1)
findNum = Cells(SRow, SCol1)
End Function
Sub caller() 'using this sub to verify the code in findNum() actually works
Dim Z As Double
Z = findNum("BigName", 178)
Windows("Analysis Sheet.xlsm").Activate
Cells(3, 31) = Z
End Sub