KaibleBasha
New Member
- Joined
- Aug 8, 2014
- Messages
- 36
Hi,
Are you able to see where I would be getting stuck in the below?
I am trying to ascertain which values in a given cell are matching the values in cells B,C,D,E,F & G2
I have 5 groups of data (hence z<6), 24 columns (hence Y<=t(where t is increased to 24)) and 35 rows (hence x<=u(where u is increased to 35)). I haven't set any actions for z as yet as it keeps crashing in the first set.
Dim b As Integer, c As Integer, d As Integer, e As Integer, f As Integer, g As Integer, w As Integer
b = Range("B2").Value
c = Range("C2").Value
d = Range("D2").Value
e = Range("E2").Value
f = Range("F2").Value
g = Range("G2").Value
w = Range("J2").Value
Dim x As Integer, y As Integer, z As Integer, t As Integer, u As Integer
z = 1
y = 2 'column 2 ("B")
x = 5 'row 5
t = 8 'up to column 8 ("H")
u = 12 'down to row 12
On Error Resume Next
Do While z < 6
Do While y <= t
If y = 8 Then y = y + 2 And t = t + 8
If y = 16 Then y = y + 2 And t = t + 8
Do While x <= u 'while 5<=12
If x = 12 Then x = x + 9 And u = u + 23 'if x=12 then x=21 and u=35
If Cells(x, y) = b Then Cells(x, y).Style = "Accent1"
If Cells(x, y) = c Then Cells(x, y).Style = "Accent1"
If Cells(x, y) = d Then Cells(x, y).Style = "Accent1"
If Cells(x, y) = e Then Cells(x, y).Style = "Accent1"
If Cells(x, y) = f Then Cells(x, y).Style = "Accent1"
If Cells(x, y) = g Then Cells(x, y).Style = "Accent1"
x = x + 1
Loop
If x = 35 Then x = x - 30 And u = u - 23 'if x=35 then x=5 and u=12
y = y + 1 'moves one column to the right e.g. 2 is column "B", 3 is "C" etc etc to a max of column "X".
Loop
z = z + 1
Loop
My pc stops when I try to run this which is why I think it's stuck in the loops as it should only go round 5 times right?
Thanks
Kai
Are you able to see where I would be getting stuck in the below?
I am trying to ascertain which values in a given cell are matching the values in cells B,C,D,E,F & G2
I have 5 groups of data (hence z<6), 24 columns (hence Y<=t(where t is increased to 24)) and 35 rows (hence x<=u(where u is increased to 35)). I haven't set any actions for z as yet as it keeps crashing in the first set.
Dim b As Integer, c As Integer, d As Integer, e As Integer, f As Integer, g As Integer, w As Integer
b = Range("B2").Value
c = Range("C2").Value
d = Range("D2").Value
e = Range("E2").Value
f = Range("F2").Value
g = Range("G2").Value
w = Range("J2").Value
Dim x As Integer, y As Integer, z As Integer, t As Integer, u As Integer
z = 1
y = 2 'column 2 ("B")
x = 5 'row 5
t = 8 'up to column 8 ("H")
u = 12 'down to row 12
On Error Resume Next
Do While z < 6
Do While y <= t
If y = 8 Then y = y + 2 And t = t + 8
If y = 16 Then y = y + 2 And t = t + 8
Do While x <= u 'while 5<=12
If x = 12 Then x = x + 9 And u = u + 23 'if x=12 then x=21 and u=35
If Cells(x, y) = b Then Cells(x, y).Style = "Accent1"
If Cells(x, y) = c Then Cells(x, y).Style = "Accent1"
If Cells(x, y) = d Then Cells(x, y).Style = "Accent1"
If Cells(x, y) = e Then Cells(x, y).Style = "Accent1"
If Cells(x, y) = f Then Cells(x, y).Style = "Accent1"
If Cells(x, y) = g Then Cells(x, y).Style = "Accent1"
x = x + 1
Loop
If x = 35 Then x = x - 30 And u = u - 23 'if x=35 then x=5 and u=12
y = y + 1 'moves one column to the right e.g. 2 is column "B", 3 is "C" etc etc to a max of column "X".
Loop
z = z + 1
Loop
My pc stops when I try to run this which is why I think it's stuck in the loops as it should only go round 5 times right?
Thanks
Kai