Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Syntax of If statement in before print event


In the before print event, I need code to execute only for a particula
worksheet named "Checks" (code name Sheet2). I have tried th
following as well as variations but can't get the if statement to wor
properly:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Active.Worksheets.Name = "Checks" Then
(code goes here)
Else
(other code goes here)
End If
End Sub

I'm trying to keep it simple. Any ideas? Thanks so very much
mikebur

--
mikebur
-----------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458
View this thread: http://www.excelforum.com/showthread.php?threadid=46635

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Syntax of If statement in before print event

Hi Mike,

Try:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Checks" Then
MsgBox "Located"
Else
MsgBox "Not the sheet!"
End If
End Sub


---
Regards,
Norman



"mikeburg" wrote in
message ...

In the before print event, I need code to execute only for a particular
worksheet named "Checks" (code name Sheet2). I have tried the
following as well as variations but can't get the if statement to work
properly:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Active.Worksheets.Name = "Checks" Then
(code goes here)
Else
(other code goes here)
End If
End Sub

I'm trying to keep it simple. Any ideas? Thanks so very much.
mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile:
http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=466356



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Syntax of If statement in before print event

You may want to just apply the code to both Checks and all the other worksheets,
too.

Just because the worksheet isn't active, doesn't mean it's not being printed.

mikeburg wrote:

In the before print event, I need code to execute only for a particular
worksheet named "Checks" (code name Sheet2). I have tried the
following as well as variations but can't get the if statement to work
properly:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Active.Worksheets.Name = "Checks" Then
(code goes here)
Else
(other code goes here)
End If
End Sub

I'm trying to keep it simple. Any ideas? Thanks so very much.
mikeburg

--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=466356


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Syntax of If statement in before print event


Thanks so very much. It's amazing when you are learning, sometimes th
simplest problems are the hardest to remember! You are a life saver.
mikebur

--
mikebur
-----------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458
View this thread: http://www.excelforum.com/showthread.php?threadid=46635

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement syntax Sander Excel Discussion (Misc queries) 4 July 14th 09 06:04 PM
if statement syntax help OfficeManager Excel Worksheet Functions 6 July 23rd 08 08:09 PM
need help with syntax of if statement Melody Excel Worksheet Functions 3 February 15th 08 05:05 PM
need help with syntax of a Workbook Event Paul Simon[_2_] Excel Programming 3 July 30th 03 03:43 AM


All times are GMT +1. The time now is 10:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"