函数例程中的单元寻址 [英] Cell Addressing in Function Routine
问题描述
我有一个函数例程,它按如下方式处理数据:
GETVOLFLOW = Sheets(datsht).Cells(arow + 38,acol + 1)
datsht,arow和acol已定义,并且例程正常工作,除非我打开包含相同工作表名称的第二个工作簿并执行重新计算。该函数将数据返回到两个工作簿,但是来自活动工作簿,而不是函数调用的
工作簿。
我相信,我需要包含工作簿路径但不知道如何编写声明。
帮助将不胜感激。
尝试
GETVOLFLOW = Application.Caller.Parent.Parent.Sheets(datsht).Cells(arow + 38,acol + 1)
应用程序。调用者是包含公式的单元格。
Application.Caller.Parent是包含该单元格的工作表。
Application.Caller.Parent.Parent是包含该工作表的工作簿。
I have a function routine that addresses data as follows:
GETVOLFLOW = Sheets(datsht).Cells(arow + 38, acol + 1)
datsht, arow and acol are defined and the routine works properly unless I have a second workbook open containing the same sheet name and perform a recalculate. The function returns data to both workbooks but from the active workbook, not the workbook from which the function call was made.
I need to include the workbook path, I believe, but do not know how to code the statement.
Help would be appreciated.
Try
GETVOLFLOW = Application.Caller.Parent.Parent.Sheets(datsht).Cells(arow + 38, acol + 1)
Application.Caller is the cell containing the formula.
Application.Caller.Parent is the worksheet containing that cell.
Application.Caller.Parent.Parent is the workbook containing that worksheet.
这篇关于函数例程中的单元寻址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!