matlab-use-spreadsheet-link

Exchange data between Excel and MATLAB using Spreadsheet Link VBA macros and worksheet functions.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-use-spreadsheet-link
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-use-spreadsheet-link
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/computational-finance/matlab-use-spreadsheet-link
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-use-spreadsheet-link

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing Excel VBA macros that communicate with MATLAB requires knowing the exact Spreadsheet Link API semantics, such as which functions are queued versus immediate, and small mistakes like passing a Range object instead of a string cause silent failures. This Skill provides the correct function signatures, queuing rules, and code generation patterns for building Excel-to-MATLAB workflows.

Core Features & Use Cases

  • Data Exchange Functions: Covers MLPutMatrix, MLGetMatrix, MLPutVar, MLGetVar, MLPutRanges, and MLAppendMatrix for moving data between Excel ranges, VBA variables, and the MATLAB workspace.
  • Command Execution and Figures: Uses MLEvalString to run MATLAB code from Excel and MLGetFigure with MatlabRequest to import MATLAB plots as images into worksheets.
  • Use Case: A financial analyst keeps portfolio prices in Excel and wants MATLAB to compute a total return index and chart. The Skill generates a VBA macro that exports the ranges, runs the MATLAB computation, writes results back to cells, and embeds the figure.

Quick Start

Write an Excel VBA macro that sends the range A1:B100 to MATLAB, computes the column means, and writes the result back to cell E1.

Frequently Asked Questions about matlab-use-spreadsheet-link

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call MATLAB from an Excel VBA macro?

Use Spreadsheet Link functions inside a VBA macro: export data with MLPutMatrix or MLPutVar, run MATLAB code with MLEvalString, and retrieve results with MLGetVar or MLGetMatrix. End the macro with MatlabRequest if you used MLGetMatrix or MLGetFigure.

What is the difference between MLPutVar and MLPutMatrix in Spreadsheet Link?

MLPutMatrix reads an Excel range directly into a MATLAB variable and works in both VBA and worksheet formulas. MLPutVar exports a VBA variable to MATLAB and is VBA-only, making it better when data needs VBA manipulation before or after MATLAB processing.

Why is MLGetMatrix not writing results to my Excel cells?

MLGetMatrix is queued and does not execute immediately in VBA macros. You must call MatlabRequest as the last statement of the macro to process all pending MLGetMatrix and MLGetFigure commands and write results to the worksheet.

Does Spreadsheet Link work on Mac or Linux?

No, Spreadsheet Link is Windows only because it communicates with MATLAB through the MATLAB COM Server. MATLAB must also be running locally before the macros execute.

How do I import a MATLAB plot into Excel?

Select the destination cell with Range(...).Select, then call MLGetFigure with width and height scaling factors, followed by MatlabRequest. For multiple figures, make each figure current with figure(N) in MATLAB before each MLGetFigure call.

When should I not use Spreadsheet Link for MATLAB integration?

Avoid it for MATLAB-only workflows with no Excel involvement, Python or .NET integration where the MATLAB Engine API fits better, and web service deployment where MATLAB Production Server is the appropriate tool.