Error in my code?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am receiving an "Object Required" Error when I run this code. I want the colorindex to change on this group of cells before the spreadsheet prints. Can I not reference an object on the spreadsheet in the This Workbook area? Is there a better way to do this? Thanks in advance. Matt

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.BlackAndWhite = True
If cbExempt.Value = True Then
Range("C31,E31,G31,I31,K31,M31,O31").Font.ColorIndex = 2
End If
End Sub
 
Where is cbExempt? (assume it is an activeX combobox) It should have some
qualification on it. I put Activesheet as an illustration.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.BlackAndWhite = True
If Activesheet.cbExempt.Value = True Then
ActiveSheet.Range("C31,E31,G31,I31,K31,M31,O31").Font.ColorIndex = 2
End If
End Sub

--
Regards,
Tom Ogilvy


Matt said:
I am receiving an "Object Required" Error when I run this code. I want
the colorindex to change on this group of cells before the spreadsheet
prints. Can I not reference an object on the spreadsheet in the This
Workbook area? Is there a better way to do this? Thanks in advance. Matt
 
I think it depends on the printer. Some printers recognize there is no
contrast and correct for it - I guess yours does that.

--
Regards,
Tom Ogilvy

Matt said:
Yes, it is an activeX combobox. If I set the page setup to .BlackAndWhite
can I not change the color of text to white? I changed the code to give it
qualification but it still prints the text in black. The combo box is on
Sheet1. Thanks.
 
sheet1.cbExempt.Value

or

IF Worksheets("sheet1").cbExempt.Value = True then

--
Regards,
Tom Ogilvy

Matt said:
How would I reference my combo box? My combo box name is cbExempt. If I
were referencing it, how would I finish this statement:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Run-time error from my code 5
Run Error while protected 1
2 codes in one sheet 5
Run - time error '1004' 1
Two codes in one set. 1
Problem w/ Print Macro 3
VBA code does not work 7
Code Error 3

Back
Top