Convert number to Characters

thomasdk

New Member
Joined
Sep 19, 2014
Messages
2
Hi.
I want to make a counter that counts from 0 to 456.976 (26 * 26 * 26 * 26)
I have made the first tasks in VBS. The number is stored in a textfile. I load the number and place it in a document.
Add one to the number and save it to a textfile. No problem.

The problem is converting the number to Characters (by script):
1 = A
2 = B
3 = C
26 = Z
27 = AA
28 = AB
29 = AC
ETC.
Do you have any good suggestions how to approach This task ?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

ParamRay

Well-known Member
Joined
Aug 6, 2014
Messages
1,195
.
.

You could use this function:

Code:
Function col_ref(col_index As Integer)

    If col_index >= 1 And col_index <= Columns.Count Then
        col_ref = Columns(col_index).Address(ColumnAbsolute:=False)
        col_ref = Left(col_ref, InStr(col_ref, ":") - 1)
    Else
        col_ref = CVErr(xlErrNum)
    End If

End Function

(Note that if you're calling this function from another VBA procedure then you'll need to have a worksheet active when calling it.)
 

VBA Geek

MrExcel MVP
Joined
Dec 16, 2013
Messages
2,857
Code:
Function getPtrn(ByVal I As Long) As String
Const Letters As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim sRes As String, iLen As Integer, k As Long
iLen = Len(Letters)
sRes = Mid$(Letters, ((I - 1) Mod iLen) + 1, 1)
I = Int((I - 1) / iLen)
Do Until I = 0
    sRes = Mid$(Letters, ((I - 1) Mod iLen) + 1, 1) & sRes
    I = Int((I - 1) / iLen)
Loop
getPtrn = sRes
End Function






Hi.
I want to make a counter that counts from 0 to 456.976 (26 * 26 * 26 * 26)
I have made the first tasks in VBS. The number is stored in a textfile. I load the number and place it in a document.
Add one to the number and save it to a textfile. No problem.

The problem is converting the number to Characters (by script):
1 = A
2 = B
3 = C
26 = Z
27 = AA
28 = AB
29 = AC
ETC.
Do you have any good suggestions how to approach This task ?
 

Watch MrExcel Video

Forum statistics

Threads
1,129,577
Messages
5,637,190
Members
416,960
Latest member
Carbon1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top