# Convert number to Characters

#### thomasdk

##### New Member
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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},\$Z\$1:\$Z\$99,\$Y\$1:\$Y\$99),2,False) to lookup Y values to left of Z values.
.
.

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 = 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.)

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 ?

VBA GEEK - You are a genius Thanks and have a great weekend.

Replies
0
Views
142
Replies
2
Views
212
Replies
5
Views
268
Replies
0
Views
580
Replies
5
Views
278

1,207,421
Messages
6,078,436
Members
446,337
Latest member
nrijkers

### 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.

### Which adblocker are you using?

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

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