View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default Convert Column Number to Column Letter

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



"Philosophaie" wrote:

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