Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop from a to z
I need to loop from a to z.
say for i=a to z ...... next How can I do it? Regards, Madiya |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop from a to z
one way is something like this:
Sub test() Dim i As Integer For i = Asc("a") To Asc("z") Debug.Print Chr(i) Next i End Sub -- Hope that helps. Vergel Adriano "Madiya" wrote: I need to loop from a to z. say for i=a to z ...... next How can I do it? Regards, Madiya |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop from a to z
I need to loop from a to z.
say for i=a to z ..... next How can I do it? Here is one way to do it directly as you wrote it... Enum Letters a = 97: b: c: d: e: f: g: h: i: j: k: l: m n = 110: o: p: q: r: s: t: u: v: w: x: y: z End Enum Sub test() Dim X As Variant For X = a To z Debug.Print Chr(X) Next End Sub Note that the Enum can be one single line long, like this... Enum Letters a = 97: b: c: d: e: f: g: h: i: j: k: l: m: n: o: p: q: r: s: t: u: v: w: x: y: z End Enum but I didn't do it because I suspect the line would wrap in most newsreaders. If it did, and you copied it that way, the first letter on the wrapped line would be taken as a Line Label by VB; so, I figured it was better to break it up for clarity during copying... make it into one line after you place it into your code. Note... while I used lower case letters in the Enum and in the For-Next loop, the casing it not significant... upper case letters work exactly the same as lower case within the code... the output, however, will still be lower case because the Enum starts its assignment at 97 (the ASCII code for lower case 'a'). Rick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Naming Worksheets - Loop within a loop issue | Excel Programming | |||
Naming Worksheets - Loop within a loop issue | Excel Programming | |||
(Complex) Loop within loop to create worksheets | Excel Programming | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming |