# Incrementing by Alphabets, and A1,B1,C1..A2,B2,C2

I have a process where in a loop i add an Alphabet letter at the end of a string to differentiate them, i have static string called

alphabetes = “abcdefghijklmnopqrstuvwxyz”

Then in the loop based on a different criteria i say

Name = Name+alphabets(index).ToString.ToUpper

that becomes NameA,NameB,NameC etc

Issue

Problem is my loop is dynamic, some times it will loop 5 times and some time it have to loop 500 times

Obviously this will fail the `Name = Name+alphabets(index).ToString.ToUpper` due to running out of letter (` Index was outside the bounds of the array.`)

My requirement

My requirement is to have the End result looks like this : NameA,NameB…NameZ,NameA1,NameB1…NameZ1,NameA2,NameB2 etc

How can i achieve this ?

attaching my sample file here

code test.xaml (8.3 KB)

XX stands for a counter index and a variable can be used for

1 Like

Your inner loop must reset position after value 25 (or 26 English alphabets), back to value 0 (or back to letter A) . And this condition will trigger every time outer loop limit is > 26.

Here is the draft code:

Let Outer_Limit = 50 (dynamic and can change all the time)
Let alphaArray = {‘A’,‘B’,…‘Z’} (number of alphabets is fixed at 26)
Let index=0
For X = 0 to Outer_Limit-1
if index>Length(alphaArray)-1 then
'when loop runs
'first time this condition will be true when index reaches value 26. Here X=26, and index = 26
'X can continue all the way to 50, but index has to restart from 0 so that it can return to letter A
index=0
else
’ this condition will be true as long as index is between 0 and 25 .
index=index+1
end
'when you reach here index will be any value between 0 and 25
'X can continue to keep incrementing as usual
Let thisLetter = alphaArray(index)
Let thisName = “Name”+thisLetter+X.toString()
Next X

what XX are you referring to ?

Lets assume you have series from 0,1,2…57 XX stands for the current counter index e.g. 46

and with replacing 46 with a variable holding 46 or other value the oneliner can be dynamized

1 Like

and 0.1 and 65 is part of the formula?

yes
65 is the asci Code for A

with 0.1 Addition we over come the 0 based index and can ceiling / uprounding to next int Number

1 Like

thanks i got it was missing char