K
Ksu
Hi
I am using the following If and ElseIf statement to compare cell's.
'1a
If [C5] = [B2] Then
[B5].Value = "1b"
ElseIf [D5] = [B2] Then
[B5].Value = "2a"
ElseIf [E5] = [B2] Then
[B5].Value = "2b"
ElseIf [F5] = [B2] Then
[B5].Value = "3a"
ElseIf [G5] = [B2] Then
[B5].Value = "3b"
ElseIf [H5] = [B2] Then
[B5].Value = "4a"
ElseIf [I5] = [B2] Then
[B5].Value = "4b"
ElseIf [J5] = [B2] Then
[B5].Value = "5a"
ElseIf [K5] = [B2] Then
[B5].Value = "5b"
ElseIf [L5] = [B2] Then
[B5].Value = "6a"
ElseIf [M5] = [B2] Then
[B5].Value = "6b"
ElseIf [N5] = [B2] Then
[B5].Value = "7a"
ElseIf [O5] = [B2] Then
[B5].Value = "7b"
ElseIf [P5] = [B2] Then
[B5].Value = "8a"
ElseIf [Q5] = [B2] Then
[B5].Value = "8b"
ElseIf [R5] = [B2] Then
[B5].Value = "9a"
ElseIf [S5] = [B2] Then
[B5].Value = "9b"
ElseIf [T5] = [B2] Then
[B5].Value = "10a"
ElseIf [U5] = [B2] Then
[B5].Value = "10b"
End If
'1b
If [B5] = [C2] Then
[C5].Value = "1a"
ElseIf [D5] = [C2] Then
[C5].Value = "2a"
ElseIf [E5] = [C2] Then
[C5].Value = "2b"
ElseIf [F5] = [C2] Then
[C5].Value = "3a"
ElseIf [G5] = [C2] Then
[C5].Value = "3b"
ElseIf [H5] = [C2] Then
[C5].Value = "4a"
ElseIf [I5] = [C2] Then
[C5].Value = "4b"
ElseIf [J5] = [C2] Then
[C5].Value = "5a"
ElseIf [K5] = [C2] Then
[C5].Value = "5b"
ElseIf [L5] = [C2] Then
[C5].Value = "6a"
ElseIf [M5] = [C2] Then
[C5].Value = "6b"
ElseIf [N5] = [C2] Then
[C5].Value = "7a"
ElseIf [O5] = [C2] Then
[C5].Value = "7b"
ElseIf [P5] = [C2] Then
[C5].Value = "8a"
ElseIf [Q5] = [C2] Then
[C5].Value = "8b"
ElseIf [R5] = [C2] Then
[C5].Value = "9a"
ElseIf [S5] = [C2] Then
[C5].Value = "9b"
ElseIf [T5] = [C2] Then
[C5].Value = "10a"
ElseIf [U5] = [C2] Then
[C5].Value = "10b"
End If
'2a
If [B5] = [D2] Then
[D5].Value = "1a"
ElseIf [C5] = [D2] Then
[D5].Value = "1b"
ElseIf [E5] = [D2] Then
[D5].Value = "2b"
ElseIf [F5] = [D2] Then
[D5].Value = "3a"
ElseIf [G5] = [D2] Then
[D5].Value = "3b"
ElseIf [H5] = [D2] Then
[D5].Value = "4a"
ElseIf [I5] = [D2] Then
[D5].Value = "4b"
ElseIf [J5] = [D2] Then
[D5].Value = "5a"
ElseIf [K5] = [D2] Then
[D5].Value = "5b"
ElseIf [L5] = [D2] Then
[D5].Value = "6a"
ElseIf [M5] = [D2] Then
[D5].Value = "6b"
ElseIf [N5] = [D2] Then
[D5].Value = "7a"
ElseIf [O5] = [D2] Then
[D5].Value = "7b"
ElseIf [P5] = [D2] Then
[D5].Value = "8a"
ElseIf [Q5] = [D2] Then
[D5].Value = "8b"
ElseIf [R5] = [D2] Then
[D5].Value = "9a"
ElseIf [S5] = [D2] Then
[D5].Value = "9b"
ElseIf [T5] = [D2] Then
[D5].Value = "10a"
ElseIf [U5] = [D2] Then
[D5].Value = "10b"
End If
'2b
If [B5] = [E2] Then
[E5].Value = "1a"
ElseIf [C5] = [E2] Then
[E5].Value = "1b"
ElseIf [D5] = [E2] Then
[E5].Value = "2a"
ElseIf [F5] = [E2] Then
[E5].Value = "3a"
ElseIf [G5] = [E2] Then
[E5].Value = "3b"
ElseIf [H5] = [E2] Then
[E5].Value = "4a"
ElseIf [I5] = [E2] Then
[E5].Value = "4b"
ElseIf [J5] = [E2] Then
[E5].Value = "5a"
ElseIf [K5] = [E2] Then
[E5].Value = "5b"
ElseIf [L5] = [E2] Then
[E5].Value = "6a"
ElseIf [M5] = [E2] Then
[E5].Value = "6b"
ElseIf [N5] = [E2] Then
[E5].Value = "7a"
ElseIf [O5] = [E2] Then
[E5].Value = "7b"
ElseIf [P5] = [E2] Then
[E5].Value = "8a"
ElseIf [Q5] = [E2] Then
[E5].Value = "8b"
ElseIf [R5] = [E2] Then
[E5].Value = "9a"
ElseIf [S5] = [E2] Then
[E5].Value = "9b"
ElseIf [T5] = [E2] Then
[E5].Value = "10a"
ElseIf [U5] = [E2] Then
[E5].Value = "10b"
End If
'3a
If [B5] = [F2] Then
[F5].Value = "1a"
ElseIf [C5] = [F2] Then
[F5].Value = "1b"
ElseIf [D5] = [F2] Then
[F5].Value = "2a"
ElseIf [E5] = [F2] Then
[F5].Value = "2b"
ElseIf [G5] = [F2] Then
[F5].Value = "3b"
ElseIf [H5] = [F2] Then
[F5].Value = "4a"
ElseIf [I5] = [F2] Then
[F5].Value = "4b"
ElseIf [J5] = [F2] Then
[F5].Value = "5a"
ElseIf [K5] = [F2] Then
[F5].Value = "5b"
ElseIf [L5] = [F2] Then
[F5].Value = "6a"
ElseIf [M5] = [F2] Then
[F5].Value = "6b"
ElseIf [N5] = [F2] Then
[F5].Value = "7a"
ElseIf [O5] = [F2] Then
[F5].Value = "7b"
ElseIf [P5] = [F2] Then
[F5].Value = "8a"
ElseIf [Q5] = [F2] Then
[F5].Value = "8b"
ElseIf [R5] = [F2] Then
[F5].Value = "9a"
ElseIf [S5] = [F2] Then
[F5].Value = "9b"
ElseIf [T5] = [F2] Then
[F5].Value = "10a"
ElseIf [U5] = [F2] Then
[F5].Value = "10b"
End If
End Sub
And my problem is that I need to compare cell's B5 to U5, B11 to U11, B17
to U17, B23 to U23 and so on all the way to B299 to U299 so is there better /
smarter way to do this.
HELP AND ADVICE'S WOULD BE APPRECIATED
I am using the following If and ElseIf statement to compare cell's.
'1a
If [C5] = [B2] Then
[B5].Value = "1b"
ElseIf [D5] = [B2] Then
[B5].Value = "2a"
ElseIf [E5] = [B2] Then
[B5].Value = "2b"
ElseIf [F5] = [B2] Then
[B5].Value = "3a"
ElseIf [G5] = [B2] Then
[B5].Value = "3b"
ElseIf [H5] = [B2] Then
[B5].Value = "4a"
ElseIf [I5] = [B2] Then
[B5].Value = "4b"
ElseIf [J5] = [B2] Then
[B5].Value = "5a"
ElseIf [K5] = [B2] Then
[B5].Value = "5b"
ElseIf [L5] = [B2] Then
[B5].Value = "6a"
ElseIf [M5] = [B2] Then
[B5].Value = "6b"
ElseIf [N5] = [B2] Then
[B5].Value = "7a"
ElseIf [O5] = [B2] Then
[B5].Value = "7b"
ElseIf [P5] = [B2] Then
[B5].Value = "8a"
ElseIf [Q5] = [B2] Then
[B5].Value = "8b"
ElseIf [R5] = [B2] Then
[B5].Value = "9a"
ElseIf [S5] = [B2] Then
[B5].Value = "9b"
ElseIf [T5] = [B2] Then
[B5].Value = "10a"
ElseIf [U5] = [B2] Then
[B5].Value = "10b"
End If
'1b
If [B5] = [C2] Then
[C5].Value = "1a"
ElseIf [D5] = [C2] Then
[C5].Value = "2a"
ElseIf [E5] = [C2] Then
[C5].Value = "2b"
ElseIf [F5] = [C2] Then
[C5].Value = "3a"
ElseIf [G5] = [C2] Then
[C5].Value = "3b"
ElseIf [H5] = [C2] Then
[C5].Value = "4a"
ElseIf [I5] = [C2] Then
[C5].Value = "4b"
ElseIf [J5] = [C2] Then
[C5].Value = "5a"
ElseIf [K5] = [C2] Then
[C5].Value = "5b"
ElseIf [L5] = [C2] Then
[C5].Value = "6a"
ElseIf [M5] = [C2] Then
[C5].Value = "6b"
ElseIf [N5] = [C2] Then
[C5].Value = "7a"
ElseIf [O5] = [C2] Then
[C5].Value = "7b"
ElseIf [P5] = [C2] Then
[C5].Value = "8a"
ElseIf [Q5] = [C2] Then
[C5].Value = "8b"
ElseIf [R5] = [C2] Then
[C5].Value = "9a"
ElseIf [S5] = [C2] Then
[C5].Value = "9b"
ElseIf [T5] = [C2] Then
[C5].Value = "10a"
ElseIf [U5] = [C2] Then
[C5].Value = "10b"
End If
'2a
If [B5] = [D2] Then
[D5].Value = "1a"
ElseIf [C5] = [D2] Then
[D5].Value = "1b"
ElseIf [E5] = [D2] Then
[D5].Value = "2b"
ElseIf [F5] = [D2] Then
[D5].Value = "3a"
ElseIf [G5] = [D2] Then
[D5].Value = "3b"
ElseIf [H5] = [D2] Then
[D5].Value = "4a"
ElseIf [I5] = [D2] Then
[D5].Value = "4b"
ElseIf [J5] = [D2] Then
[D5].Value = "5a"
ElseIf [K5] = [D2] Then
[D5].Value = "5b"
ElseIf [L5] = [D2] Then
[D5].Value = "6a"
ElseIf [M5] = [D2] Then
[D5].Value = "6b"
ElseIf [N5] = [D2] Then
[D5].Value = "7a"
ElseIf [O5] = [D2] Then
[D5].Value = "7b"
ElseIf [P5] = [D2] Then
[D5].Value = "8a"
ElseIf [Q5] = [D2] Then
[D5].Value = "8b"
ElseIf [R5] = [D2] Then
[D5].Value = "9a"
ElseIf [S5] = [D2] Then
[D5].Value = "9b"
ElseIf [T5] = [D2] Then
[D5].Value = "10a"
ElseIf [U5] = [D2] Then
[D5].Value = "10b"
End If
'2b
If [B5] = [E2] Then
[E5].Value = "1a"
ElseIf [C5] = [E2] Then
[E5].Value = "1b"
ElseIf [D5] = [E2] Then
[E5].Value = "2a"
ElseIf [F5] = [E2] Then
[E5].Value = "3a"
ElseIf [G5] = [E2] Then
[E5].Value = "3b"
ElseIf [H5] = [E2] Then
[E5].Value = "4a"
ElseIf [I5] = [E2] Then
[E5].Value = "4b"
ElseIf [J5] = [E2] Then
[E5].Value = "5a"
ElseIf [K5] = [E2] Then
[E5].Value = "5b"
ElseIf [L5] = [E2] Then
[E5].Value = "6a"
ElseIf [M5] = [E2] Then
[E5].Value = "6b"
ElseIf [N5] = [E2] Then
[E5].Value = "7a"
ElseIf [O5] = [E2] Then
[E5].Value = "7b"
ElseIf [P5] = [E2] Then
[E5].Value = "8a"
ElseIf [Q5] = [E2] Then
[E5].Value = "8b"
ElseIf [R5] = [E2] Then
[E5].Value = "9a"
ElseIf [S5] = [E2] Then
[E5].Value = "9b"
ElseIf [T5] = [E2] Then
[E5].Value = "10a"
ElseIf [U5] = [E2] Then
[E5].Value = "10b"
End If
'3a
If [B5] = [F2] Then
[F5].Value = "1a"
ElseIf [C5] = [F2] Then
[F5].Value = "1b"
ElseIf [D5] = [F2] Then
[F5].Value = "2a"
ElseIf [E5] = [F2] Then
[F5].Value = "2b"
ElseIf [G5] = [F2] Then
[F5].Value = "3b"
ElseIf [H5] = [F2] Then
[F5].Value = "4a"
ElseIf [I5] = [F2] Then
[F5].Value = "4b"
ElseIf [J5] = [F2] Then
[F5].Value = "5a"
ElseIf [K5] = [F2] Then
[F5].Value = "5b"
ElseIf [L5] = [F2] Then
[F5].Value = "6a"
ElseIf [M5] = [F2] Then
[F5].Value = "6b"
ElseIf [N5] = [F2] Then
[F5].Value = "7a"
ElseIf [O5] = [F2] Then
[F5].Value = "7b"
ElseIf [P5] = [F2] Then
[F5].Value = "8a"
ElseIf [Q5] = [F2] Then
[F5].Value = "8b"
ElseIf [R5] = [F2] Then
[F5].Value = "9a"
ElseIf [S5] = [F2] Then
[F5].Value = "9b"
ElseIf [T5] = [F2] Then
[F5].Value = "10a"
ElseIf [U5] = [F2] Then
[F5].Value = "10b"
End If
End Sub
And my problem is that I need to compare cell's B5 to U5, B11 to U11, B17
to U17, B23 to U23 and so on all the way to B299 to U299 so is there better /
smarter way to do this.
HELP AND ADVICE'S WOULD BE APPRECIATED