Create a gist now

Instantly share code, notes, and snippets.

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];
end
aa = a1;
a1 = [a1,int2str(row)];
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment