PC Review


Reply
Thread Tools Rate Thread

Convert Column Number to Column Letter

 
 
Philosophaie
Guest
Posts: n/a
 
      5th Mar 2010
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 With Quote
 
 
 
 
JLatham
Guest
Posts: n/a
 
      5th Mar 2010
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Column number to a letter? e.g. Column 203 = GU M Skabialka Microsoft Excel Discussion 11 29th Jul 2009 05:12 PM
Convert column letter to number? Frank Marousek Microsoft Excel Programming 4 19th Oct 2006 05:10 PM
convert column number to letter lvcha.gouqizi Microsoft Excel Programming 16 31st Oct 2005 03:39 PM
Re: Example: how to convert a column letter to a number Ron de Bruin Microsoft Excel Programming 1 16th Sep 2004 05:01 PM
convert column number to letter(s) =?Utf-8?B?U2NvdHQ=?= Microsoft Excel Worksheet Functions 1 13th Nov 2003 04:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:41 AM.