Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Convert column letter to number?

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?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Convert column letter to number?

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" wrote in message ...
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?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Convert column letter to number?

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?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Convert column letter to number?

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?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Convert column letter to number?

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
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 number to letter Gord Dibben Excel Programming 1 October 31st 05 03:39 PM
convert column number to letter Harald Staff Excel Programming 7 October 25th 05 03:42 PM
convert column number to letter lvcha.gouqizi Excel Programming 1 October 24th 05 09:37 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 03:54 AM.

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"