Skip to content

Instantly share code, notes, and snippets.

@mikofski
Created November 25, 2014 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikofski/bcd1ccf813f1088cfcd9 to your computer and use it in GitHub Desktop.
Save mikofski/bcd1ccf813f1088cfcd9 to your computer and use it in GitHub Desktop.
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