Solved

Column Letter to a Column Number

Posted on 2013-06-28
2
309 Views
Last Modified: 2013-06-28
vba...

Is this code correct?

If i pass "A" = strLet

It comes back as "1" should it not be "0"



Public Function ColumnLetterToNumber(strLet As String)

Dim InputLetter As String
Dim OutputNumber As Integer
Dim Leng As Integer
Dim i As Integer

'InputLetter = InputBox("The Converting letter?")  ' Input the Column Letter

Leng = Len(strLet)
OutputNumber = 0


For i = 1 To Leng
   OutputNumber = (Asc(UCase(Mid(strLet, i, 1))) - 64) + OutputNumber * 26
Next i

'MsgBox OutputNumber   'Output the corresponding number
LtoN = OutputNumber


End Function


Freakin out on columns...
Columns start with  zero  ?





Thanks
fordraiders
0
Comment
Question by:fordraiders
2 Comments
 
LVL 13

Accepted Solution

by:
Shanan212 earned 500 total points
ID: 39284731
OutputNumber = Columns(strLet).Column

Open in new window


Try that instead of loop. You don't even need a function as this one liner can be used in other source procedures
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39285488
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now