tammiebrannon
New Member
- Joined
- Dec 28, 2011
- Messages
- 2
I am using the function below. It works fine if I call it in the following manner;
BillableHours = GetValue(fldpath, ThisDateFileName, "IngenuitE Time Card", "D16")
with the "D16" hard coded.
I need to search the closed file and determine where the billable hours will be stored, so I have created a var string;
billableAddress As String
within the loop and when location is found ;
billableAddress = Cells(totalRow, c + 1).Address(False, False)
and then I call the GetValue as follows;
BillableHours = GetValue(fldpath, ThisDateFileName, "Time Card", BillableAddress)
T then recieve the error;
Run-time error "13':
Type mismatch
Private Function GetValue(path, file, sheet, ref)
' Retrieves a value from a closed workbook
' Note: You cannot use this function in a worksheet formula.
Dim arg As String
' Make sure the file exists
' On Error GoTo ErrHandler
If Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
'GetValue = "File Not Found"
GetValue = 0
Exit Function
End If
' Create the argument
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)
' Execute an XLM macro
GetValue = ExecuteExcel4Macro(arg)
End Function
Please help ...new VBA as you can tell.... this is driving me crazy!!!
BillableHours = GetValue(fldpath, ThisDateFileName, "IngenuitE Time Card", "D16")
with the "D16" hard coded.
I need to search the closed file and determine where the billable hours will be stored, so I have created a var string;
billableAddress As String
within the loop and when location is found ;
billableAddress = Cells(totalRow, c + 1).Address(False, False)
and then I call the GetValue as follows;
BillableHours = GetValue(fldpath, ThisDateFileName, "Time Card", BillableAddress)
T then recieve the error;
Run-time error "13':
Type mismatch
Private Function GetValue(path, file, sheet, ref)
' Retrieves a value from a closed workbook
' Note: You cannot use this function in a worksheet formula.
Dim arg As String
' Make sure the file exists
' On Error GoTo ErrHandler
If Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
'GetValue = "File Not Found"
GetValue = 0
Exit Function
End If
' Create the argument
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)
' Execute an XLM macro
GetValue = ExecuteExcel4Macro(arg)
End Function
Please help ...new VBA as you can tell.... this is driving me crazy!!!