Here's the function definition:
Public Function StockQuote(strSymbol As String) As Double
It's stored in a module in an already-loaded worksheet ("My Macros.xlsm", in my Startup folder).
I want to call it from another workbook, as a cell reference:
Workbook1.xlsm cell A1:
=StockQuote("AAPL")
But all i get are NAME errors.
=My Macros.xlsm!StockQuote("AAPL")
='C:\\SomeFolder\\My Macros.xlsm'!StockQuote("AAPL")
Work either.
But in order to work you shoud open the My Macros.xlsm workbook after Workbook1.xlsm, from the excel window of Workbook1.xlsm
尝试将包含该功能的XLSM工作簿另存为XLAM:打开XLAM时,其他工作簿应该能够看到您的UDF。
How about something like this.
It should run when the worksheet is activated and put the return value of your function in cell A1.
Private Sub Worksheet_Activate()
Range("A1") = StockQuote("AAPL")
End Sub
You may need to structure it differently if the current worksheet can't see your function
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.