This example checks to see whether user_sheet is a worksheet object (and not a module sheet or something else). If it is a worksheet, it checks the worksheet and its parent (the workbook) for Crystal Ball data. If user_sheet is not a worksheet or if no Crystal Ball data exist on either the worksheet or the workbook, it displays an error message and exits the macro. Otherwise, it continues.
Set user_sheet = Worksheets("Sheet2") If (Not (TypeName(user_sheet) = "Worksheet")) Or _ (Not (CB.IsCBObject(user_sheet) Or _ CB.IsCBObject(user_sheet.Parent))) Then MsgBox "Active document does not contain Crystal Ball Data." Exit Sub End If