always_confused
Board Regular
- Joined
- Feb 19, 2021
- Messages
- 68
- Office Version
- 2016
- Platform
- Windows
Hello. I would like delete a button if it exists. I cannot find the syntax that allows for the case where it doesn't exist. I would like something like
I'm not sure how to write the condition. The Delete part works, but if the button does not exist I get an error because the button to delete cannot be found (which makes sense but I'd like to avoid this for the end user).
VBA Code:
If “CommandButton1” Exists Then
ActiveSheet.Shapes(“CommandButton1”).Delete
End If
I'm not sure how to write the condition. The Delete part works, but if the button does not exist I get an error because the button to delete cannot be found (which makes sense but I'd like to avoid this for the end user).