S
salgud
I used this sequence of IF statements to count the occurences of various
sub-codes of the code "16" in a spreadsheet I did a couple of years ago. It
works fine. But it seems to me I could do the same thing with a Case
statement, I just can't figure out how. Here is the code as is:
For Each rCell In rReason
'Counts Reason Code 16 Contact codes R, A, B & G
If rCell = "16" Then
lCt = InStr(1, UCase(rCell.Offset(0, 2).Value), "R")
If lCt > 0 Then
l16Rct = l16Rct + 1
lCt = 0
End If
lCt = InStr(1, UCase(rCell.Offset(0, 2).Value), "A")
If lCt > 0 Then
l16Act = l16Act + 1
lCt = 0
End If
lCt = InStr(1, UCase(rCell.Offset(0, 2).Value), "B")
If lCt > 0 Then
l16BGct = l16BGct + 1
Else
lCt = InStr(1, UCase(rCell.Offset(0, 2).Value), "G")
If lCt > 0 Then
l16BGct = l16BGct + 1
lCt = 0
End If
End If
End If
Next rCell
Does anyone see how this could be done using a Case statement?
Thanks in advance.
sub-codes of the code "16" in a spreadsheet I did a couple of years ago. It
works fine. But it seems to me I could do the same thing with a Case
statement, I just can't figure out how. Here is the code as is:
For Each rCell In rReason
'Counts Reason Code 16 Contact codes R, A, B & G
If rCell = "16" Then
lCt = InStr(1, UCase(rCell.Offset(0, 2).Value), "R")
If lCt > 0 Then
l16Rct = l16Rct + 1
lCt = 0
End If
lCt = InStr(1, UCase(rCell.Offset(0, 2).Value), "A")
If lCt > 0 Then
l16Act = l16Act + 1
lCt = 0
End If
lCt = InStr(1, UCase(rCell.Offset(0, 2).Value), "B")
If lCt > 0 Then
l16BGct = l16BGct + 1
Else
lCt = InStr(1, UCase(rCell.Offset(0, 2).Value), "G")
If lCt > 0 Then
l16BGct = l16BGct + 1
lCt = 0
End If
End If
End If
Next rCell
Does anyone see how this could be done using a Case statement?
Thanks in advance.