View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] vvaidya@pol.net is offline
external usenet poster
 
Posts: 24
Default Correct syntax for Active Worksheet

Hello:
I am trying to write VBA code to display a message in the Workbook,
BeforePrint event.
I have three worksheets in the workbook, named SheetA, SheetB, and
SheetC.

I want a different message to show depending upon whether SheetA is the
active sheet, or SheetB or SheetC

The code would look something like this:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet = Sheets("SheetA") Then MsgBox "Hello"
etc etc
End Sub

Obviously, I am not using the correct syntax "ActiveSheet" as it is
giving me an error.

I would appreciate if you could help me with the correct syntax

TIA

Vinay