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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
.
.

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.)
 
Upvote 0
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 ?
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,686
Members
449,048
Latest member
81jamesacct

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
Back
Top