I loop a with:
x=50
for i=1 to x
...
next x
possible to set a block of 5 for i...
example:
i=5
then print i & "A"
next block of i=5
then print i & "B"
ecc...
to the end:
1 A
2 A
3 A
4 A
5 A
6 B
7 B
8 B
9 B
10 B
11 C
12 C
...
Ecc
note:
using the standard sequntial letter of alphabet
for next with block of 5
-
- Administrator
- Posts: 79447
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: for next with block of 5
Code: Select all
Dim x As Long
Dim i As Long
For i = 1 To x
Debug.Print i & Chr(64 + (i - 1) \ 5)
Next i
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 616
- Joined: 27 Jun 2021, 10:46
Re: for next with block of 5
Hans - almost exactly the same as the code I was just about to post!
-
- PlatinumLounger
- Posts: 4497
- Joined: 26 Apr 2010, 17:36
Re: for next with block of 5
GREAT!HansV wrote: ↑31 Oct 2023, 17:07Code: Select all
Dim x As Long Dim i As Long For i = 1 To x Debug.Print i & Chr(64 + (i - 1) \ 5) Next i
OPS..
with:
Dim X As Long
Dim I As Long
X = 50
For I = 1 To X
Debug.Print I & Chr(64 + (I - 1) \ 5)
Next I
i have:
1@
2@
3@
4@
5@
6A
7A
8A
9A
10A
11B
12B
13B
14B
15B
16C
17C
18C
19C
20C
21D
22D
23D
24D
25D
26E
27E
28E
29E
30E
31F
32F
33F
34F
35F
36G
37G
38G
39G
40G
41H
42H
43H
44H
45H
46I
47I
48I
49I
50I
-
- PlatinumLounger
- Posts: 4497
- Joined: 26 Apr 2010, 17:36
-
- 5StarLounger
- Posts: 616
- Joined: 27 Jun 2021, 10:46
Re: for next with block of 5
65 is the ASCII/ANSI value for "A"
-
- 2StarLounger
- Posts: 166
- Joined: 11 Jun 2012, 20:37
Re: for next with block of 5
What happens after 130Z?
This?: or perhaps this? (like the column names at the top of an Excel sheet):
If so:
This?: or perhaps this? (like the column names at the top of an Excel sheet):
If so:
Code: Select all
Debug.Print i & Split(Cells(1, (i - 1) \ 5 + 1).Address, "$")(1)
You do not have the required permissions to view the files attached to this post.
-
- 5StarLounger
- Posts: 616
- Joined: 27 Jun 2021, 10:46
Re: for next with block of 5
sal21 uses vb6 not Excel, so that rather cunning solution sadly won't work for them
-
- PlatinumLounger
- Posts: 4497
- Joined: 26 Apr 2010, 17:36