PC Review


Reply
Thread Tools Rate Thread

Convert column letter to number?

 
 
Frank Marousek
Guest
Posts: n/a
 
      19th Oct 2006
I'm writing a Sub that accepts a column letter as input in a UserForm. I
would like to convert this column letter to a column number for use in my
code. How is this done?


 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      19th Oct 2006
You can try this Frank

Dim str As String
str = "D"

MsgBox Columns(str).Column


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Frank Marousek" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> I'm writing a Sub that accepts a column letter as input in a UserForm. I
> would like to convert this column letter to a column number for use in my
> code. How is this done?
>
>



 
Reply With Quote
 
=?Utf-8?B?Q2hhcmxlcyBDaGlja2VyaW5n?=
Guest
Posts: n/a
 
      19th Oct 2006
Why can't you use the letter?
strInput = Inputbox("Letter")
Range(strInput & 1).Select
Cells(1, strInput).Select

otherwise, if the activesheet is a worksheet then use this:
ColumnNumber = Range(strInput & 1).Column
--
Charles Chickering

"A good example is twice the value of good advice."


"Frank Marousek" wrote:

> I'm writing a Sub that accepts a column letter as input in a UserForm. I
> would like to convert this column letter to a column number for use in my
> code. How is this done?
>
>
>

 
Reply With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      19th Oct 2006
Hi
This sub will return 36

Public Sub tester()
Dim Letter As String
Letter = "AJ"
MsgBox Columns(Letter & ":" & Letter).Column
End Sub

Replace letter with your UserForm input.
regards
Paul

Frank Marousek wrote:
> I'm writing a Sub that accepts a column letter as input in a UserForm. I
> would like to convert this column letter to a column number for use in my
> code. How is this done?


 
Reply With Quote
 
Frank Marousek
Guest
Posts: n/a
 
      19th Oct 2006
> Why can't you use the letter?

Using the letter works fine. It was a rookie mistake. I was getting a "Type
mismatch" error which I thought was being caused because I was feeding a
string into where an integer was expected, but it turns out that error was
being caused by something else.

Thank you!


 
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
Column Header - Convert a Number to a letter stickandrock Microsoft Excel Misc 1 9th Jun 2008 07:54 PM
convert column number to letter lvcha.gouqizi Microsoft Excel Programming 16 31st Oct 2005 03:39 PM
Convert Column letter to number =?Utf-8?B?c2x5bWVhdA==?= Microsoft Excel Programming 5 27th Oct 2005 07:13 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.