How do I return a range of cells as an output of an Excel Builder object in VBA function?
11 次查看(过去 30 天)
显示 更早的评论
I am trying to fill an Excel cell array with the output of a function defined in my Excel Builder Component. I know how to place the output of the function in a single cell. However, I do not know how to fill an array of cells.
For example:
If I have the function in VBA:
Function foo(x1 As Variant) As Variant
Dim aClass As Object
Dim y As Variant 'output
aClass = CreateObject("mycomponent.myclass.1_0")
Call aClass.foo(1,y,x1)
foo = y
End Function
In Excel, I would like to pass the following range of cells into this function:
A1:1
A2:2
A3:3
and have it output to the range:
B1:B3
This is simple to implement if I used a VBA subfunction.
采纳的回答
MathWorks Support Team
2012-9-10
You can return an array of cells from a MATLAB Excel Builder component by entering the formula as an array formula. This is accomplished by pressing CTRL+SHIFT+ENTER.
Select cells B1-B3, and enter the formula,
=foo(A1:A3)
Again to evaluate as an array formula, press CTRL+SHIFT+ENTER.
Consult the Excel documentation for more information on array formulas.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Export to MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!