File Exchange

image thumbnail

Column Converter for Excel

version (2.25 KB) by Kevin Crosby
Convert Excel column letters to numbers or vice versa, for processing data to/from XLSREAD/XLSWRITE.


Updated 02 Aug 2010

View Version History

View License

B = XLSCOL(A) takes input A, and converts to corresponding output B. The input may be a number, a string, an array or matrix, an Excel range, a cell, or a combination of each within a cell, including nested cells and arrays.

The output maintains the shape of the input and attempts to "flatten" the cell to remove nesting.

Numbers and symbols within strings or Excel ranges are ignored.

xlscol(256) % returns 'IV'
xlscol('IV') % returns 256
xlscol('A1:IV65536') % returns [1 256]

See more examples in help comments.

CELLFUN and ARRAYFUN allow the program to recursively handle multiple inputs. An interesting side effect is that mixed input, nested cells, and matrix shapes can be processed.

I adapted the modular math from Mike Sheppard's program ExcelCol, to properly handle the conversion from column number to strings. His program is at

Cite As

Kevin Crosby (2021). Column Converter for Excel (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (18)

Jerome Baranger

Perfect! Works great. Thank you for sharing.

Babak Afsharipour

Fantastic code! Thank you very much.

David Saidman

Chuanqiang Zhang

Ryan Bell

Troy Bouman

Works as expected. Thank you!

Devin Cohen

small script, extremely easy to use. thanks!

Michael Dakos

Even 8 years after release, well done mate!

Julien Leger

Monika Jaskolka

Works great! Very helpful.

Piotr Balik

Andrés Argüello


Ben Cole


Grant Coleman

Florian Aendekerk

Love it!

Richard Crozier

Nice, thanks.

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: xlsrange

Community Treasure Hunt

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

Start Hunting!