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
 

marcel49

New Member
Joined
Jun 8, 2019
Messages
10
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
33,806
Office Version
365
Platform
Windows
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
 

marcel49

New Member
Joined
Jun 8, 2019
Messages
10
Re: before print even

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

Thank you very much
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
33,806
Office Version
365
Platform
Windows
Re: before print even

You're welcome & thanks for the feedback
 

Forum statistics

Threads
1,085,703
Messages
5,385,323
Members
401,938
Latest member
JustinTaster

Some videos you may like

This Week's Hot Topics

Top