LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Can this be done as a Case statement?

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.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Case statement Ken[_4_] Excel Programming 4 January 26th 09 10:07 PM
Case Statement jlclyde Excel Discussion (Misc queries) 3 December 4th 08 05:04 PM
Case Of Statement hfazal Excel Programming 2 February 14th 06 08:18 PM
Case Statement Help stck2mlon Excel Programming 3 June 2nd 04 01:44 PM
Case statement smi Excel Programming 2 October 18th 03 02:20 PM


All times are GMT +1. The time now is 06:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"