Calling a function from within a function

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
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top