I have a procedure that should only start if a condition is met.
In this example the condition is ActiveWindow.Zoom = 200
Trying to use a MsgBox
with vbOkCancel
to say:
Issue: The code starts the procedure, if the active window zoom is already set to 200. Otherwise, it only sets the zoom to 200 and exits.
Sub AddChart()
'...
If Not ActiveWindow.Zoom = 200 Then
MsgBox "Set Window Zoom to: 200%", vbOKCancel
Else
ActiveWindow.Zoom = 200
Set ws = ActiveSheet
With ws
'...
End With
End If
End Sub
Your code tests if the Zoom is set to 200. If it is not, it warns you to change it. If it is, it sets it anyway..?
You should use:
If Not ActiveWindow.Zoom = 200 Then
MsgBox "Setting Window Zoom to: 200%", vbOKOnly
ActiveWindow.Zoom = 200
End If