Question : Exit code and display message box depending on cell value

I am using:

Dim MoveForwardValue As Integer
MoveForwardValue = Range("AC5").Value
If MoveForwardValue = 0 Then
...
Else
MsgBox "Type must balance to ZERO!"
End If

THe code is running no matter what is in cell AC5 I want it to exit unless cell = 0.

Answer : Exit code and display message box depending on cell value

you have 2 options:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
Dim MoveForwardValue As Integer
MoveForwardValue = Range("AC5").Value
If MoveForwardValue = 0 Then
...
Else
MsgBox "Type must balance to ZERO!"
Exit Sub
End If

' or

Dim MoveForwardValue As Integer
MoveForwardValue = Range("AC5").Value
If MoveForwardValue = 0 Then
...
Else
MsgBox "Type must balance to ZERO!"
GoTo err
End If

err:
End Sub
Random Solutions  
 
programming4us programming4us