Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Convert Column Number to Column Letter

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert column letter to number? Frank Marousek Excel Programming 4 October 19th 06 05:10 PM
convert column number to letter Gord Dibben Excel Programming 1 October 31st 05 03:39 PM
Convert Column letter to number slymeat Excel Programming 5 October 27th 05 07:13 PM
convert column number to letter Bob Phillips[_6_] Excel Programming 0 October 24th 05 09:03 PM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"