Link to home
Start Free TrialLog in
Avatar of Frank Freese
Frank FreeseFlag for United States of America

asked on

If..Then or Case Else

Folks,
I am using the code below in a command button click event. It works. So my question is there a better way to do this - like using the Case...Else which I am not "yet" comfortable with?


 Dim QtrTotal As Integer							
     QtrTotal = 1571							
     If Range("B7") <> QtrTotal Then							
        MsgBox "1st Qtr Total Hamburgers is incorrect!", vbOKOnly, "Incorrect Answer"							
        Worksheets("2DLine").Range("B7").ClearContents							
        Range("B7").Select							
Exit Sub							
End If							
     QtrTotal = 1271							
     If Range("C7") <> QtrTotal Then							
        MsgBox "1st Qtr Total Milk Shakes is incorrect!", vbOKOnly, "Incorrect Answer"							
        Worksheets("2DLine").Range("C7").ClearContents							
        Range("C7").Select							
Exit Sub							
End If							
     QtrTotal = 238							
     If Range("D7") <> QtrTotal Then							
        MsgBox "1st Qtr Total Salads is incorrect!", vbOKOnly, "Incorrect Answer"							
        Worksheets("2DLine").Range("D7").ClearContents							
        Range("D7").Select							
Exit Sub							
End If							
     QtrTotal = 642		              					
     If Range("E7") <> QtrTotal Then							
        MsgBox "1st Qtr Total Drinks is incorrect!", vbOKOnly, "Incorrect Answer"							
        Worksheets("2DLine").Range("E7").ClearContents							
        Range("E7").Select							
Exit Sub							
End If							

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Kimputer
Kimputer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Frank Freese

ASKER

thanks...I wasn't heading to la-la land
Avatar of englanddg
englanddg

I agree with Kimputer.

I mean, you could use a Case...but then you'd have to update some variable for the cell reference...probably not worth it (and over-complicating things).
thanks for the affirmation
appreciate it