Hello so I have a variable range similar to this one:
I tailored a macro I found here to work for me and I came up with this
But for some reason this code is skipping some numbers? Any idea as to what is causing this? Or how I can fix it?
Debits(21450).xlsx | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | |||
1 | |||||||||||
2 | |||||||||||
3 | Heading | ||||||||||
4 | xxxx | ||||||||||
5 | xxxx | ||||||||||
6 | |||||||||||
7 | |||||||||||
8 | NYC | Bronx | 2/11/2022 | Jan-22 | P-1041 | App | 0 | 70.14 | 220.00 | ||
9 | NYC | Bronx | 2/12/2022 | Jan-22 | P-1042 | App | 0 | 110.15 | 0.00 | ||
10 | NYC | Bronx | 2/13/2022 | Jan-22 | P-1043 | App | 0 | 150.35 | 0.00 | ||
11 | NYC | Bronx | 2/14/2022 | Jan-22 | P-1044 | App | 0 | 500.35 | 0.00 | ||
12 | NYC | Bronx | 2/15/2022 | Jan-22 | P-1045 | App | 0 | 176.55 | 0.00 | ||
13 | NYC | Bronx | 2/16/2022 | Jan-22 | P-1046 | App | 0 | 157.14 | 0.00 | ||
14 | NYC | Bronx | 2/17/2022 | Jan-22 | P-1047 | App | 0 | 927.94 | 0.00 | ||
15 | NYC | Bronx | 2/18/2022 | Jan-22 | P-1048 | App | 0 | 121.80 | 0.00 | ||
16 | NYC | Bronx | 2/19/2022 | Jan-22 | P-1049 | App | 0 | 271.77 | 0.00 | ||
17 | NYC | Bronx | 2/20/2022 | Jan-22 | P-1050 | App | 0 | 31.23 | 0.00 | ||
18 | NYC | Bronx | 2/21/2022 | Jan-22 | P-1051 | App | 0 | 70.00 | 0.00 | ||
19 | NYC | Bronx | 2/22/2022 | Jan-22 | P-1052 | App | 0 | 1,500.50 | 0.00 | ||
20 | NYC | Bronx | 2/23/2022 | Jan-22 | P-1053 | App | 0 | 70.14 | 0.00 | ||
21 | NYC | Bronx | 2/24/2022 | Jan-22 | P-1054 | App | 0 | 110.15 | 0.00 | ||
22 | NYC | Bronx | 2/25/2022 | Jan-22 | P-1055 | App | 0 | 150.35 | 0.00 | ||
23 | NYC | Bronx | 2/26/2022 | Jan-22 | P-1056 | App | 0 | 500.35 | 0.00 | ||
24 | NYC | Bronx | 2/27/2022 | Jan-22 | P-1057 | App | 0 | 176.55 | 0.00 | ||
25 | NYC | Bronx | 2/28/2022 | Jan-22 | P-1058 | App | 0 | 157.14 | 0.00 | ||
26 | NYC | Bronx | 3/1/2022 | Jan-22 | P-1059 | App | 0 | 927.94 | 0.00 | ||
27 | NYC | Bronx | 3/2/2022 | Jan-22 | P-1060 | App | 0 | 121.80 | 0.00 | ||
28 | NYC | Bronx | 3/3/2022 | Jan-22 | P-1061 | App | 0 | 271.77 | 0.00 | ||
29 | NYC | Bronx | 3/4/2022 | Jan-22 | P-1062 | App | 0 | 31.23 | 70.14 | ||
30 | NYC | Bronx | 3/5/2022 | Jan-22 | P-1063 | App | 0 | 70.00 | 110.15 | ||
31 | NYC | Bronx | 3/6/2022 | Jan-22 | P-1064 | App | 0 | 1,500.50 | 150.35 | ||
32 | NYC | Bronx | 3/7/2022 | Jan-22 | P-1065 | App | 0 | 0.00 | 500.35 | ||
33 | NYC | Bronx | 3/8/2022 | Jan-22 | P-1066 | App | 0 | 0.00 | 176.55 | ||
34 | NYC | Bronx | 3/9/2022 | Jan-22 | P-1067 | App | 0 | 0.00 | 157.14 | ||
35 | NYC | Bronx | 3/10/2022 | Jan-22 | P-1068 | App | 0 | 0.00 | 927.94 | ||
36 | NYC | Bronx | 3/11/2022 | Jan-22 | P-1069 | App | 0 | 0.00 | 121.80 | ||
37 | NYC | Bronx | 3/12/2022 | Jan-22 | P-1070 | App | 0 | 0.00 | 271.77 | ||
38 | NYC | Bronx | 3/13/2022 | Jan-22 | P-1071 | App | 0 | 0.00 | 31.23 | ||
39 | NYC | Bronx | 3/14/2022 | Jan-22 | P-1072 | App | 0 | 0.00 | 70.00 | ||
40 | NYC | Bronx | 3/15/2022 | Jan-22 | P-1073 | App | 0 | 0.00 | 1,500.50 | ||
41 | NYC | Bronx | 2/24/2022 | Jan-22 | P-1054 | App | 0 | 0.00 | 110.15 | ||
42 | NYC | Bronx | 2/25/2022 | Jan-22 | P-1055 | App | 0 | 0.00 | 150.35 | ||
43 | NYC | Bronx | 2/26/2022 | Jan-22 | P-1056 | App | 0 | 0.00 | 500.35 | ||
44 | NYC | Bronx | 2/27/2022 | Jan-22 | P-1057 | App | 0 | 0.00 | 176.55 | ||
45 | NYC | Bronx | 2/28/2022 | Jan-22 | P-1058 | App | 0 | 0.00 | 157.14 | ||
46 | NYC | Bronx | 3/1/2022 | Jan-22 | P-1059 | App | 0 | 0.00 | 927.94 | ||
47 | NYC | Bronx | 3/2/2022 | Jan-22 | P-1060 | App | 0 | 0.00 | 121.80 | ||
48 | NYC | Bronx | 3/3/2022 | Jan-22 | P-1061 | App | 0 | 0.00 | 271.77 | ||
Report1 |
I tailored a macro I found here to work for me and I came up with this
VBA Code:
Sub DebitsNCredits()
Dim c As Range, r As Range, f As Range, n As Long, cell As String
n = 8
Set r = Range("H8", Range("H" & Rows.Count).End(3))
r.Interior.ColorIndex = xlNone
For Each c In Range("I8", Range("I" & Rows.Count).End(3))
If c.Value <> "" Then
Set f = r.Find(c, , xlValues, xlWhole)
If Not f Is Nothing Then
cell = f.Address
Do
If f.Interior.ColorIndex = xlNone Then
f.Interior.ColorIndex = n
c.Interior.ColorIndex = n
n = n + 1
If n = 56 Then n = 8
Exit Do
End If
Set f = r.FindNext(f)
Loop While Not f Is Nothing And f.Address <> cell
End If
End If
Next
End Sub
But for some reason this code is skipping some numbers? Any idea as to what is causing this? Or how I can fix it?
Debits(21450).xlsx | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | |||
1 | |||||||||||
2 | |||||||||||
3 | Heading | ||||||||||
4 | xxxx | ||||||||||
5 | xxxx | ||||||||||
6 | |||||||||||
7 | |||||||||||
8 | NYC | Bronx | 2/11/2022 | Jan-22 | P-1041 | App | 0 | 70.14 | 220.00 | ||
9 | NYC | Bronx | 2/12/2022 | Jan-22 | P-1042 | App | 0 | 110.15 | 0.00 | ||
10 | NYC | Bronx | 2/13/2022 | Jan-22 | P-1043 | App | 0 | 150.35 | 0.00 | ||
11 | NYC | Bronx | 2/14/2022 | Jan-22 | P-1044 | App | 0 | 500.35 | 0.00 | ||
12 | NYC | Bronx | 2/15/2022 | Jan-22 | P-1045 | App | 0 | 176.55 | 0.00 | ||
13 | NYC | Bronx | 2/16/2022 | Jan-22 | P-1046 | App | 0 | 157.14 | 0.00 | ||
14 | NYC | Bronx | 2/17/2022 | Jan-22 | P-1047 | App | 0 | 927.94 | 0.00 | ||
15 | NYC | Bronx | 2/18/2022 | Jan-22 | P-1048 | App | 0 | 121.80 | 0.00 | ||
16 | NYC | Bronx | 2/19/2022 | Jan-22 | P-1049 | App | 0 | 271.77 | 0.00 | ||
17 | NYC | Bronx | 2/20/2022 | Jan-22 | P-1050 | App | 0 | 31.23 | 0.00 | ||
18 | NYC | Bronx | 2/21/2022 | Jan-22 | P-1051 | App | 0 | 70.00 | 0.00 | ||
19 | NYC | Bronx | 2/22/2022 | Jan-22 | P-1052 | App | 0 | 1,500.50 | 0.00 | ||
20 | NYC | Bronx | 2/23/2022 | Jan-22 | P-1053 | App | 0 | 70.14 | 0.00 | ||
21 | NYC | Bronx | 2/24/2022 | Jan-22 | P-1054 | App | 0 | 110.15 | 0.00 | ||
22 | NYC | Bronx | 2/25/2022 | Jan-22 | P-1055 | App | 0 | 150.35 | 0.00 | ||
23 | NYC | Bronx | 2/26/2022 | Jan-22 | P-1056 | App | 0 | 500.35 | 0.00 | ||
24 | NYC | Bronx | 2/27/2022 | Jan-22 | P-1057 | App | 0 | 176.55 | 0.00 | ||
25 | NYC | Bronx | 2/28/2022 | Jan-22 | P-1058 | App | 0 | 157.14 | 0.00 | ||
26 | NYC | Bronx | 3/1/2022 | Jan-22 | P-1059 | App | 0 | 927.94 | 0.00 | ||
27 | NYC | Bronx | 3/2/2022 | Jan-22 | P-1060 | App | 0 | 121.80 | 0.00 | ||
28 | NYC | Bronx | 3/3/2022 | Jan-22 | P-1061 | App | 0 | 271.77 | 0.00 | ||
29 | NYC | Bronx | 3/4/2022 | Jan-22 | P-1062 | App | 0 | 31.23 | 70.14 | ||
30 | NYC | Bronx | 3/5/2022 | Jan-22 | P-1063 | App | 0 | 70.00 | 110.15 | ||
31 | NYC | Bronx | 3/6/2022 | Jan-22 | P-1064 | App | 0 | 1,500.50 | 150.35 | ||
32 | NYC | Bronx | 3/7/2022 | Jan-22 | P-1065 | App | 0 | 0.00 | 500.35 | ||
33 | NYC | Bronx | 3/8/2022 | Jan-22 | P-1066 | App | 0 | 0.00 | 176.55 | ||
34 | NYC | Bronx | 3/9/2022 | Jan-22 | P-1067 | App | 0 | 0.00 | 157.14 | ||
35 | NYC | Bronx | 3/10/2022 | Jan-22 | P-1068 | App | 0 | 0.00 | 927.94 | ||
36 | NYC | Bronx | 3/11/2022 | Jan-22 | P-1069 | App | 0 | 0.00 | 121.80 | ||
37 | NYC | Bronx | 3/12/2022 | Jan-22 | P-1070 | App | 0 | 0.00 | 271.77 | ||
38 | NYC | Bronx | 3/13/2022 | Jan-22 | P-1071 | App | 0 | 0.00 | 31.23 | ||
39 | NYC | Bronx | 3/14/2022 | Jan-22 | P-1072 | App | 0 | 0.00 | 70.00 | ||
40 | NYC | Bronx | 3/15/2022 | Jan-22 | P-1073 | App | 0 | 0.00 | 1,500.50 | ||
41 | NYC | Bronx | 2/24/2022 | Jan-22 | P-1054 | App | 0 | 0.00 | 110.15 | ||
42 | NYC | Bronx | 2/25/2022 | Jan-22 | P-1055 | App | 0 | 0.00 | 150.35 | ||
43 | NYC | Bronx | 2/26/2022 | Jan-22 | P-1056 | App | 0 | 0.00 | 500.35 | ||
44 | NYC | Bronx | 2/27/2022 | Jan-22 | P-1057 | App | 0 | 0.00 | 176.55 | ||
45 | NYC | Bronx | 2/28/2022 | Jan-22 | P-1058 | App | 0 | 0.00 | 157.14 | ||
46 | NYC | Bronx | 3/1/2022 | Jan-22 | P-1059 | App | 0 | 0.00 | 927.94 | ||
47 | NYC | Bronx | 3/2/2022 | Jan-22 | P-1060 | App | 0 | 0.00 | 121.80 | ||
48 | NYC | Bronx | 3/3/2022 | Jan-22 | P-1061 | App | 0 | 0.00 | 271.77 | ||
Report1 |