Why does MLPutRanges Return a Invalid Range Error?

4 次查看(过去 30 天)
I have set up SpreadSheet Link to allow communication between Excel and MATLAB, and generally everything is working correctly.
When using the "MLPutRanges()" function from Excel, in certain SpreadSheets I recieve an "Invalid Range" or #INVALIDRANGE! error. This does not appear consistent, the function behaves as expected in some of my Excel files, but in other files the function does not work at all. What could be the cause of this?

采纳的回答

MathWorks Support Team
There are a few possible reasons to consider.
1. The "named range" that is being sent must only reference data from a single sheet in the workbook. You cannot send a "named range" that references values across multiple sheets.
2. The "named range" must have a name that is also a legal MATLAB variable name. Since the name of the "named range" is used to define the MATLAB variable name, any "named range" that does not follow MATLAB variable name standards will result in this error. Please consult: <https://www.mathworks.com/help/matlab/matlab_prog/variable-names.html>
3. Following from (2), Excel has a notion of a hidden "named range". You will not be able to see these "named ranges" from Excels "Name Manager" user interface. If you are still experiencing this error and you have checked that all your "named ranges" have valid names, please check for hidden "named ranges". Note that people have reported issues with Excel where a hidden "named range" is automatically created, so you might not have explicitly created one. To find if there is a hidden "named range" in your Excel file, execute the following Visual Basic script in Excels Developer Visual Basic window:
Sub ShowAllNames()
Dim n As Name
For Each n In ActiveWorkbook.Names
n.Visible = True
Next n
End Sub
This will reveal any hidden "named ranges" that may exist. Check these for illegal naming.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by