?
Solved

Column Letter to a Column Number

Posted on 2013-06-28
2
Medium Priority
?
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
Shanan212 earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

764 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