Excel VBA - 从函数中读取另一个工作簿中的单元格数据

时间:2016-05-11 14:58:24

标签: excel vba excel-vba

有没有办法从excel VBA中的用户定义函数(非宏)读取另一个工作簿中的数据?

1 个答案:

答案 0 :(得分:0)

是的,尝试引用Workbook这样的

Function Plus5(Wkb as Workbook, sSheet as String, sRef as String) as Double
'' I'm guessing that is number the data you want
'' Wkb = Workbooks object, sSheet = Sheet Name; sRef = Cell Reference

Dim Wks as Worksheet
Set Wks = Wkb.Worksheets(sSheet)

Plus5 = Wks.Range(sRef) + 5

End Function