VB script to generate string from A to Z

Sunday, July 15, 2012

I just thought to share a bit of code which generate AAA, AAB, AAC.. ABA... ZZZ.
I wrote this today for a data sample project.

This code will fill the column A in an Microsoft Excel sheet , if it run as macro.

Cheers

i = 0
For X3 = 1 To 26
For X2 = 1 To 26
For X1 = 1 To 26
i = i + 1
Range("A" & i).Select
out = Chr(X3 + 64) & Chr(X2 + 64) & Chr(X1 + 64)
ActiveCell.FormulaR1C1 = out
Next
Next
Next

0 comments:

Post a Comment