print workbook in colour but not the manual highlighted cells

beca

New Member
Joined
May 17, 2011
Messages
44
Hi, I have a workbook with colour logos, and some cells have manual highlighted colours. I want to print the workbook in colour, but not the cell highlights.

Can someone please help with a macro that can remove the manual highlights in cells before printing the workbook in colour, and return the cell highlights after printing.

Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Something like this work for you?

VBA Code:
Private Sub test_highlights()
   
    With ThisWorkbook
        .Worksheets("sheet_name_here").Copy Before:=.Worksheets(1)
        With .Worksheets(1)
            .Cells.Style = "Normal"
            .PrintOut
            Application.DisplayAlerts = False
            .Delete
            Application.DisplayAlerts = True
        End With
    End With
   
End Sub

Modified the code provided in Print Without Cell Fill Color But Keep Cell Text Color
 
Upvote 0
Hi, it gives me error message as below
 

Attachments

  • 1.JPG
    1.JPG
    18.8 KB · Views: 6
  • 2.JPG
    2.JPG
    39 KB · Views: 6
Upvote 0
I edited my first post, just change it ("two") to your worksheet's name.
 
Upvote 0
Hi Gokhan, I have changed the workbook name to "2", it still shows error?
 

Attachments

  • 3.JPG
    3.JPG
    38 KB · Views: 2
Upvote 0
Hi Gokhan, I managed to run the macro. However, there are few issues:
  • The macro code removes all the formatting on the numbers.
  • The macro code removes all the boarders.
In addition, when I print the second time, the macro code does not allow me to overwrite the previous printout file.

See attached the print out from the macro code (first screenshot). the second screenshot is a colour print of the workbook, I would like to just remove the yellow highlights, and can overwrite the previous printout.
 

Attachments

  • 1.JPG
    1.JPG
    110.8 KB · Views: 5
  • 2.JPG
    2.JPG
    130.2 KB · Views: 5
Upvote 0
Try the code like this:
VBA Code:
Sub test_highlights()
    Dim str As String
    str = ActiveSheet.Name
    With ThisWorkbook
        .ActiveSheet.Copy Before:=.Worksheets(1)
        With .Worksheets(1)
            .Cells.Interior.ColorIndex = xlNone
            .PrintPreview True
            Application.DisplayAlerts = False
            .Delete
            Application.DisplayAlerts = True
        End With
        .Worksheets(str).Activate
    End With
End Sub
However, if your printout includes your sheet name somewhere it will not match.
I also posted a code in your other post. Do not post twice on the same subject, or at least mention it somewehere.
 
Upvote 0
Hi Bob, thank you for the code, and it works perfectly.

One problem though, my workbook contains several worksheets, the code above only prints one worksheet at a a time. Is it possible to print all the worksheets in one print?
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

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