Using Before_Print function

CHARLESJOSEPH

New Member
Joined
Jul 31, 2008
Messages
13
:rolleyes:

First post: Very adept at Excel functionality but total newbie to VB so please forgive my retardedness.

All I want to do is simply have a macro run when the spreadsheet is printed. I have been researching the board for the past couple hours but still can't figure it out. I have seen examples of the Before_Print function in many posts but can't seem to get it to work. I've read that the code must be inserted in the "thisworkbook module" but I can't seem to find it:confused:. When I view the VB code, all I have to choose from is "general" tab or "worksheet" tab. My code is attached.

The other question I have is if there is a way to apply VB code to the whole workbook (I am assuming there is and it is probably on the elusive "thisworkbook module.") Please someone put me out of my misery.

PS: If anyone knows of a good introductory / overview of VB for idiots, please let me know. Thanks.


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p> </o:p>
Sub Hidezero()<o:p></o:p>
For Each cell In Range("C:C")<o:p></o:p>
If cell.Value = "0" Then cell.EntireRow.Hidden = True<o:p></o:p>
Next cell<o:p></o:p>
End Sub
<o:p> </o:p>
<o:p> </o:p>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I hit another obstacle and again need some assistance. The below code is applied to all worksheets. I have a master worksheet named "CO" that I don't want the below code applied to. How would I do this?

Code:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)Application.EnableEvents = FalseIf Not Application.Intersect(Target, Sh.Range("A21:H1000")) Is Nothing Then Target(1).Value = UCase(Target(1).Value)End IfApplication.EnableEvents = TrueEnd Sub</PRE>
<!-- / message -->
 
Upvote 0
Try

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Sh.Name = "CO" Then Exit Sub
Application.EnableEvents = False
If Not Application.Intersect(Target, Sh.Range("A21:H1000")) Is Nothing Then
    Target(1).Value = UCase(Target(1).Value)
End If
Application.EnableEvents = True
End Sub
 
Upvote 0
:biggrin: VoGII - You are my idol! THanks again. I am going to get that VB for dummies thing you recommended. I appreciate all your help. - CHarles
 
Upvote 0

Forum statistics

Threads
1,215,360
Messages
6,124,491
Members
449,166
Latest member
hokjock

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top