Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 239
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 0 March 27th 07 11:17 PM
(Complex) Loop within loop to create worksheets klysell Excel Programming 1 March 20th 07 12:03 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


All times are GMT +1. The time now is 01:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"