Sheet 1
Sheet 2
Sheet1 contains a list of drawings. The numbers are in Columns C through G. One row for each drawing.
Sheet2 contains numbers 1-43 of which 5 will be selected for the next drawing.
In Sheet2 Column B (SBLO) is where I want to place the number of drawings Skipped Between the Last Occurance for each number in Column A (#).
The Sheet2 example has the results I'm seeking in Column B (SBLO) according to the latest drawings in Sheet1.
[IMPORTANT] I didn't template the full history of drawings in my Sheet1 example. The #4 on Sheet2 shows 47 skips between last occurance but to save space I didn't list the drawings that far back.
Ex. 2-6-11-13-31 was the last drawing on Sheet1 so they will have 0 skips between last occurance on Sheet2. The drawing before that on Sheet1 was 6-7-22-23-32. Numbers# 7, 22, 23, 32 on Sheet2 will have 1 skip between last occurance, 6 already has 0, etc. etc.
Hey, I know it's a lottery Sub I'm seeking but it's a fun way to learn Excel VBA.
I'm wondering whether I need to define two ranges, one in Sheet1 and one in Sheet2.
Lame attempt below. This is stuff I mashed together from my little subroutine library but it definitely has big holes in it. I'm far from being VBA proficient. I only know enough to be dangerous and always frustrated.
Thanks in advance to anyone willing to help.
ID | Date | N1 | N2 | N3 | N4 | N5 |
847 | 2/27/2021 | 10 | 16 | 17 | 24 | 36 |
848 | 2/28/2021 | 6 | 9 | 13 | 14 | 22 |
849 | 3/1/2021 | 2 | 6 | 18 | 23 | 33 |
850 | 3/2/2021 | 9 | 15 | 20 | 27 | 34 |
851 | 3/3/2021 | 19 | 22 | 23 | 24 | 35 |
852 | 3/4/2021 | 6 | 13 | 20 | 33 | 36 |
853 | 3/5/2021 | 3 | 14 | 15 | 20 | 36 |
854 | 3/6/2021 | 1 | 12 | 15 | 20 | 43 |
855 | 3/7/2021 | 11 | 15 | 16 | 18 | 43 |
856 | 3/8/2021 | 16 | 30 | 31 | 39 | 40 |
857 | 3/9/2021 | 3 | 20 | 25 | 30 | 43 |
858 | 3/10/2021 | 18 | 20 | 25 | 28 | 29 |
859 | 3/11/2021 | 2 | 10 | 13 | 29 | 30 |
860 | 3/12/2021 | 5 | 18 | 19 | 38 | 39 |
861 | 3/13/2021 | 5 | 11 | 20 | 21 | 26 |
862 | 3/14/2021 | 7 | 12 | 25 | 28 | 41 |
863 | 3/15/2021 | 13 | 37 | 38 | 39 | 43 |
864 | 3/16/2021 | 3 | 10 | 11 | 22 | 41 |
865 | 3/17/2021 | 15 | 16 | 17 | 19 | 37 |
866 | 3/18/2021 | 18 | 24 | 28 | 31 | 39 |
867 | 3/19/2021 | 5 | 13 | 22 | 27 | 34 |
868 | 3/20/2021 | 15 | 16 | 21 | 24 | 37 |
869 | 3/21/2021 | 13 | 14 | 18 | 24 | 29 |
870 | 3/22/2021 | 9 | 18 | 32 | 33 | 34 |
871 | 3/23/2021 | 1 | 12 | 18 | 32 | 36 |
872 | 3/24/2021 | 6 | 8 | 13 | 29 | 36 |
873 | 3/25/2021 | 9 | 12 | 16 | 20 | 35 |
874 | 3/26/2021 | 6 | 28 | 33 | 36 | 39 |
875 | 3/27/2021 | 6 | 7 | 22 | 23 | 32 |
876 | 3/28/2021 | 2 | 6 | 11 | 13 | 31 |
Sheet 2
# | SBLO |
1 | 5 |
2 | 0 |
3 | 12 |
4 | 47 |
5 | 9 |
6 | 0 |
7 | 1 |
8 | 4 |
9 | 3 |
10 | 12 |
11 | 0 |
12 | 3 |
13 | 0 |
14 | 7 |
15 | 8 |
16 | 3 |
17 | 11 |
18 | 5 |
19 | 11 |
20 | 3 |
21 | 8 |
22 | 1 |
23 | 1 |
24 | 6 |
25 | 14 |
26 | 15 |
27 | 9 |
28 | 2 |
29 | 4 |
30 | 17 |
31 | 0 |
32 | 1 |
33 | 2 |
34 | 6 |
35 | 3 |
36 | 2 |
37 | 8 |
38 | 13 |
39 | 2 |
40 | 20 |
41 | 12 |
42 | 37 |
43 | 13 |
Sheet1 contains a list of drawings. The numbers are in Columns C through G. One row for each drawing.
Sheet2 contains numbers 1-43 of which 5 will be selected for the next drawing.
In Sheet2 Column B (SBLO) is where I want to place the number of drawings Skipped Between the Last Occurance for each number in Column A (#).
The Sheet2 example has the results I'm seeking in Column B (SBLO) according to the latest drawings in Sheet1.
[IMPORTANT] I didn't template the full history of drawings in my Sheet1 example. The #4 on Sheet2 shows 47 skips between last occurance but to save space I didn't list the drawings that far back.
Ex. 2-6-11-13-31 was the last drawing on Sheet1 so they will have 0 skips between last occurance on Sheet2. The drawing before that on Sheet1 was 6-7-22-23-32. Numbers# 7, 22, 23, 32 on Sheet2 will have 1 skip between last occurance, 6 already has 0, etc. etc.
Hey, I know it's a lottery Sub I'm seeking but it's a fun way to learn Excel VBA.
I'm wondering whether I need to define two ranges, one in Sheet1 and one in Sheet2.
Lame attempt below. This is stuff I mashed together from my little subroutine library but it definitely has big holes in it. I'm far from being VBA proficient. I only know enough to be dangerous and always frustrated.
Thanks in advance to anyone willing to help.
VBA Code:
Sub Count_SBLO()
'
'
'
'
Dim myRange As Range
Dim c As Range
Set drwgRange = Sheet1.Range("C3", Range("G1048576").End(xlUp))
For Each c In myRange
For i = c.Row - 2 To 1 Step -1
If Not IsError(Application.Match(c, drwgRange.Rows(i), 0)) Then
c.Offset(, 1) = c.Row - 1 - i
Exit For
Else
c.Offset(, 1) = 0
End If
Next i
Next c
End Sub