View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Excel Column Number To Column Name

5.0 | 2 ratings Rate this file 19 Downloads (last 30 days) File Size: 1.76 KB File ID: #15748 Version: 1.4
image thumbnail

Excel Column Number To Column Name


Matt G (view profile)


30 Jul 2007 (Updated )

Converts an array of numbers to a cell array of Excel column names

| Watch this File

File Information

XLSCOLNUM2STR takes in an array of numbers and returns a cellular array of the same size with cell of corresponding Excel column names.

n=[1 10;
   53 256]
c={'A' , 'J';
   'BA', 'IV'}


MATLAB release MATLAB 7.3 (R2006b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
01 Mar 2016 Vladimir

09 Jul 2010 Ly Tran

Hi, I have the same problem as D S:
??? Too many inputs.

Error in ==> xlsColNum2Str at 36
colChar(colNum>=L & colNum<=U) = ...
I am using Matlab Can that be a problem?
Thank you.

Comment only
30 Jul 2009 Kevin J. Delaney

Perfect! Just what I was looking for.

12 Apr 2009 Matt G

Matt G (view profile)

The problems have been fixed.

Comment only
14 Oct 2008 Malcolm Lidierth

Some problems:
>> xlsColNum2Str(53)
ans =
>> xlsColNum2Str(1353)
ans =
>> length(unique(xlsColNum2Str(1:16384)))
ans =
not 16384.

Comment only
03 Aug 2007 Matt G

Hi D.S,

I am not sure why you are getting the error. I am not at work today but when I get in I will run the function on some different MATLAB versions. To see if I can recreate the error.


Comment only
02 Aug 2007 D S

Matt- Thanks for finding that error in 'num2abc'. I updated the logic so it should be right now.

I downloaded your function and tried running the example, but I get:

??? Too many inputs.
Error in ==> xlsColNum2Str at 36
colChar(colNum>=L & colNum<=U)=...

Comment only
02 Aug 2007 Matt G

D S,

Thanks for the comment. I took a look at NUM2ABC but it seems that there are some holes. If you run the following script:
for n=1:256

you will find that 52, 78, 104, 130, 156, 182, 208, 234 (multiples of 26) return errors.

Also as I noted in the m-file Excel 2007 has 16,384 columns. So your code would need to modified if for some reason someone needs more than 256 columns.

As for as converting from a character array to number I didn’t post my function but I will now. It is simple…

function [ colNum ] = xlsColStr2Num( colChar )

colNum=cellfun(@(x) (sum((double(x)-64).*26.^(length(x)-1:-1:0))),colChar);

Comment only
02 Aug 2007 D S

Just thought I'd mention NUM2ABC (also posted on the FEX) was made for the same task. There is also an inverse function, ABC2NUM. These functions work on a single value and return a string or an integer, respectively. These are in the "Utilities > Data Import/Export" category. I'm not sure, but that might be a better category for this submission as well.

Comment only
01 Aug 2007

Updated the summary to fit the 100 char limit

01 Oct 2007

Revised title

12 Apr 2009 1.3

Fixed bug noted by Malcolm Lidierth.

03 Aug 2009 1.4

Updated summary

Contact us