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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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,213,562
Messages
6,114,322
Members
448,564
Latest member
ED38

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