Convert Column Number to Column Letter

P

Philosophaie

I have the last column of data. I want to use a range to say copy or define
something. So how do you convert the number LastCol to a letter to display
in a Range:

LastCol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
 
J

JLatham

A web search for "convert column number to letter" turned up several hits,
one of which was:
http://www.mrexcel.com/forum/showthread.php?t=102298
look at the last 3 posts in that discussion. Two ways to get the job done.
Personally, since you've gone the route you have at this point, I'd probably
go with the solution in the last posting. Especially if you've got Excel
2007 where column letter IDs can go to 3 characters, not just 2.

You could do something like:
LastCol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
fullAddress= Cells(1, LastCol).Address
'returns something like $A$1 or $EF$1 in fullAddress
colID = Left(fullAddress, InStr(2, fullAddress, "$") - 1)
'will give you $A or $EF type returns
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top