couveman
New Member
- Joined
- Feb 17, 2011
- Messages
- 7
I have written a function xxDay(row)" that I refer to a cell on my worksheet, passing the data of another cell.
Within the xxDay function I call "ExecuteExcel4Macro" for data from a closed WB and I get #VALUE returned to the cell on my worksheet.
When I run the xxDay function as a sub it works fine, giving me the data I would expect.
The Sub:
Sub xxDay()
Dim fName, Path, strSheet, strRef, strRng, xxDay, row As Variant
row = 7
xxDay = ""
Path = "C:\MMS\"
fName = "Book1.xlsm"
strSheet = "Sheet1"
strRng = Cells(row, 3).Address(, , xlR1C1)
strRef = "'" & Path & "[" & fName & "]" & strSheet & "'!" & strRng
xxDay = ExecuteExcel4Macro(strRef)
MsgBox xxDay
End Sub
**********
The Function:
Function xxDay(row)
Dim fName, Path, strSheet, strRef, strRng As Variant
xxDay = ""
Path = "C:\MMS\"
fName = "Book1.xlsm"
strSheet = "Sheet1"
strRng = Cells(row, 3).Address(, , xlR1C1)
strRef = "'" & Path & "[" & fName & "]" & strSheet & "'!" & strRng
xxDay = ExecuteExcel4Macro(strRef)
End Function
***************
Any assistance would be greatly appreciated.
Ron
Within the xxDay function I call "ExecuteExcel4Macro" for data from a closed WB and I get #VALUE returned to the cell on my worksheet.
When I run the xxDay function as a sub it works fine, giving me the data I would expect.
The Sub:
Sub xxDay()
Dim fName, Path, strSheet, strRef, strRng, xxDay, row As Variant
row = 7
xxDay = ""
Path = "C:\MMS\"
fName = "Book1.xlsm"
strSheet = "Sheet1"
strRng = Cells(row, 3).Address(, , xlR1C1)
strRef = "'" & Path & "[" & fName & "]" & strSheet & "'!" & strRng
xxDay = ExecuteExcel4Macro(strRef)
MsgBox xxDay
End Sub
**********
The Function:
Function xxDay(row)
Dim fName, Path, strSheet, strRef, strRng As Variant
xxDay = ""
Path = "C:\MMS\"
fName = "Book1.xlsm"
strSheet = "Sheet1"
strRng = Cells(row, 3).Address(, , xlR1C1)
strRef = "'" & Path & "[" & fName & "]" & strSheet & "'!" & strRng
xxDay = ExecuteExcel4Macro(strRef)
End Function
***************
Any assistance would be greatly appreciated.
Ron
Last edited: