before print event

marcel49

New Member
Joined
Jun 8, 2019
Messages
10
Hi,

I try to change the color of the active cell before print the worksheet. I've got the following code:


Private Sub Workbook_BeforePrint(Cancel As Boolean)

Sheets("Invoice").Select

c = ActiveCell.Address

Range(c).Interior.ColorIndex = 2


Sheets("Uurlijst").Select

d = ActiveCell.Address


Range(d).Interior.ColorIndex = 2

End Sub

It is not working can somebody tell me what I do wrong in this instance

Thank you
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Re: before print even

Thank you for your reply.

I did change the colorindex to color but it goes wrong when It reaches the folowing lines of code:

Sheets("Uurlijst").Select

d = ActiveCell.Address

I get faultcode 9
 
Upvote 0
Re: before print even

If it's a "Subscript out of range" error, it would suggest that you don't have a sheet called "Uurlijst".
Check the spelling & check for any leading/trailing spaces
 
Upvote 0
Re: before print even

You are wright. I should have used "URENLIJST" instead of "Uurlijst"

Thank you very much
 
Upvote 0
Re: before print even

You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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