Sub active() If ActiveWorkbook Is Nothing Then MsgBox "open a workbook and click in it before running this macro." _ & vbCr & vbCr & "This macro will now end.", _ vbOKOnly + vbExclamation, "No Workbook Is Open" End End If End Sub