MATLAB: Is it possible to use range objects with the MLGetMatrix function in Excel Link

arraycellnanSpreadsheet Link

I am using the Excel Link MLGetMatrix function in an Excel Macro, but I need to use use a range object returned by the VBA Cells function to specify where to place the data.
For example instead of:
MLGetMatrix "X", "Sheet1!A1"
I would like to use:
MLGetMatrix("X",Cells(1,1))

Best Answer

This bug has been fixed in Release 2007a (R2007a). For previous product releases, read below for any possible workarounds:
The MLGetMatrix function can accept ranges expressed as strings; to use a range object, you will first need to convert it to string format.
The MLGetMatrix function in Excel Link takes two string inputs. The first input specifies the MATLAB variable name and the second input specifies the address of the Excel worksheet cell where the first element of the MATLAB variable should be written.
If you have a range object which refers to the location where you want to write your data, you can use the "Address" property of the range object to extract the string. For example:
Sub Get_Variable()
MLGetMatrix "X", Cells(3, 2).Address
MatlabRequest
End Sub