Stuart’s MATLAB Videos

Watch and Learn

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the Original version of the page.

Creating a Function to Format a Spreadsheet 2

Posted by Stuart McGarrity,

I often export to Excel to share results with others. In doing so I control the format of the output with a template with column widths and heading colors that I have talked about in previous videos (saving to a template, replicating a worksheet template). However, if I change the number of columns in my data, I need to change the template, which is annoying.

So here I try to make a function, where I can specify the column widths and colors as parameters, and therefore change it dynamically to match the columns in my table. It requires interacting with Excel’s object model, which I find difficult and I need to frequently refer to VBA (Visual Basic for Applications ) documentation online.

Features covered in this code-along style video include:

Follow me (@stuartmcgarrity) if you want to be notified via Twitter when I post.

Play the video in full screen mode for a better viewing experience. 

2 CommentsOldest to Newest