I'm trying to increment alphabetic characters from AA to ZZ.
The one I created is capable of incrementing alphabetic characters from A to Z.
I only need from AA to ZZ. I will use them as search terms in a webpage to populate results.
Sub GetAlphabets()Dim myvar$, I&For I = 65 To 90myvar = Chr(I)Debug.Print myvarNext IEnd Sub
Best Answer
Use a second loop
Sub GetAlphabets()Dim myvar As StringDim I As Long, J As LongFor I = 65 To 90For J = 65 To 90myvar = Chr(I) & Chr(J)Debug.Print myvarNext JNext IEnd Sub
Alternative via column addresses
The following example call needs only one loop to show all combinations:
Sub AA2ZZ()Dim i As LongFor i = 1 To 27 * 26 ' i.e. 1 * 26 for single chars, 26 * 26 for pairsDebug.Print i, Split((Columns(i).Address(, 0)), ":")(0)Next iEnd Sub