Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
retseort
 
Posts: n/a
Default Event macro that targets specific worksheet


Hi,

I have this macro and I need it to only target a specific worksheet
when it runs. Any help would be appreciated.


Code:
--------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.ScreenUpdating = False
BeginRow = 40
EndRow = 70
ChkCol = 9

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value < 6 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
Application.ScreenUpdating = True
End Sub
--------------------


--
retseort
------------------------------------------------------------------------
retseort's Profile: http://www.excelforum.com/member.php...o&userid=24690
View this thread: http://www.excelforum.com/showthread...hreadid=514023

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Event macro that targets specific worksheet

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Activesheet.Name = "mySheet" Then
Application.ScreenUpdating = False
BeginRow = 40
EndRow = 70
ChkCol = 9

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value < 6 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
Application.ScreenUpdating = True
End If
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"retseort" wrote in
message ...

Hi,

I have this macro and I need it to only target a specific worksheet
when it runs. Any help would be appreciated.


Code:
--------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.ScreenUpdating = False
BeginRow = 40
EndRow = 70
ChkCol = 9

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value < 6 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
Application.ScreenUpdating = True
End Sub
--------------------


--
retseort
------------------------------------------------------------------------
retseort's Profile:

http://www.excelforum.com/member.php...o&userid=24690
View this thread: http://www.excelforum.com/showthread...hreadid=514023



  #3   Report Post  
Posted to microsoft.public.excel.misc
Jim May
 
Posts: n/a
Default Event macro that targets specific worksheet

Say your specific worksheet is (named) MySpecial

After
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.ScreenUpdating = False

"Add" -- If activesheet.name = "MySpecial" then
Your existing code here...

"retseort" wrote in
message ...

Hi,

I have this macro and I need it to only target a specific worksheet
when it runs. Any help would be appreciated.


Code:
--------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.ScreenUpdating = False
BeginRow = 40
EndRow = 70
ChkCol = 9

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value < 6 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
Application.ScreenUpdating = True
End Sub
--------------------


--
retseort
------------------------------------------------------------------------
retseort's Profile:
http://www.excelforum.com/member.php...o&userid=24690
View this thread: http://www.excelforum.com/showthread...hreadid=514023



  #4   Report Post  
Posted to microsoft.public.excel.misc
retseort
 
Posts: n/a
Default Event macro that targets specific worksheet


Thanks for the responses. I tried the suggestions and the code does
nothing. Here is the code as per your suggestion.

Basically this code looks at rows 40 thru 70 and hides all rows that
are blank. I want it to run when I save or print.


Code:
--------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "CLIENT_SOW" Then
Application.ScreenUpdating = False
BeginRow = 40
EndRow = 70
ChkCol = 9

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value < 6 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
Application.ScreenUpdating = True
End If
End Sub
--------------------


--
retseort
------------------------------------------------------------------------
retseort's Profile: http://www.excelforum.com/member.php...o&userid=24690
View this thread: http://www.excelforum.com/showthread...hreadid=514023

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
Need help updating my macro to include a 2nd worksheet. billrl34 Excel Worksheet Functions 0 December 9th 05 08:06 PM
Help with a macro to open to a specific worksheet EAHRENS Excel Worksheet Functions 0 November 30th 05 08:36 PM
I need help with a macro which will copy a worksheet and.. Greegan Excel Worksheet Functions 2 July 29th 05 11:48 PM
Open workbook to specific worksheet Dave Excel Discussion (Misc queries) 2 May 2nd 05 08:44 PM
Worksheet Row Change event crazybass2 Excel Discussion (Misc queries) 4 December 8th 04 05:29 PM


All times are GMT +1. The time now is 01:34 AM.

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

About Us

"It's about Microsoft Excel"