Skip to content

Instantly share code, notes, and snippets.

@mikofski mikofski/rc2a1.m
Created Nov 25, 2014

What would you like to do?
convert MS Excel row-column reference to A1 reference
function [a1,aa] = rc2a1(row,col)
% RC2A1 convert row, column reference to A1 reference for excel
% A1 = RC2A1(ROW,COL) returns the equivalent reference as a string
% for the given row, ROW, and column, COL, numbers.
a1 = char(64+mod(col-1,26)+1);
xcol = ceil(col/26)-1;
if xcol>0
[~,aa] = rc2a1(row,xcol);
a1 = [aa,a1];
aa = a1;
a1 = [a1,int2str(row)];
You can’t perform that action at this time.