ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to Write Error Trap (https://www.excelbanter.com/excel-programming/429707-how-write-error-trap.html)

GavinS

How to Write Error Trap
 
I have the following code to toggle between print preview and normal
view but I need to add an error statement just in case there is no
sheet open.

Can someone please suggest how I might write this.

Thanks

Sub TogglePrintView()

If ActiveWindow.View = xlPageBreakPreview Then
ActiveWindow.View = xlNormalView
ElseIf ActiveWindow.View = xlNormalView Then
ActiveWindow.View = xlPageBreakPreview
End If
End Sub


All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com