![]() |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 07:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com