Print the workbook in colour but not the cell highlights

beca

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

Is there a way to do this?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Are the cell highlights conditional formatting or manually filled?
If it is conditional formatting then yes, there is a relatively easy way.
Otherwise a macro has to loop through all cells, save the formatting, then clear it, then print, then return the formatting to the cells.
 
Upvote 0
Hi, the cell highlights are a mix of manual and conditional formatting. A bit of pain.
 
Upvote 0
What I do when I want to print like this is select a cell, usually A1, and put a value in it, 1 or TRUE.
Then include its value in the conditional formatting. Whe I change its value to 0 or FALSE all conditional formatting disappears. Then I can print.
 
Upvote 0
Thanks Bob, what about manual highlights? In fact, conditional formatting colours are not shown, it only highlights when the value is out of the range.

It is the manual highlights that I want to remove before printing.

Is there a macro code to do this kind of task?
 
Upvote 0
Here is a code - 2 subs, one saves the cells colors and clears them the second one restores them.
it's sort of a quick draft and far from refined but it works. Since the colors are saved in a variable you should restore them before it is lost.
My next idea is to store them in an additional hidden sheet, but I can't promise when I will write it.
VBA Code:
Option Explicit

Const sfx = "_col"
Dim cArr
Dim Csaved As Boolean

Sub saveColors()
    If Csaved Then
        If vbNo = MsgBox("Colors are already saved. Do you want to erase the saved colors?", vbYesNo + vbQuestion + vbDefaultButton2) Then
            Exit Sub
        End If
    End If
    On Error Resume Next
    Csaved = False
    Erase cArr
    
    Dim wb As Workbook
    Set wb = ThisWorkbook
    Dim sh As Worksheet, sh2 As Worksheet
    Set sh = wb.ActiveSheet
    Dim rng As Range, cc As Range
    Set rng = sh.UsedRange
    
    Dim i As Long, j As Long
    ReDim cArr(0 To 2, 0 To 0)
    
    For Each cc In rng
        With cc
            If .Interior.ColorIndex <> xlNone Then
                ReDim Preserve cArr(0 To 2, 0 To i)
                cArr(0, i) = .Parent.Name
                cArr(1, i) = .Address(0, 0)
                cArr(2, i) = .Interior.Color
                .Interior.ColorIndex = xlNone
                i = i + 1
            End If
        End With
    Next cc
    If i > 0 Then Csaved = True Else cArr = Null
ep:
    On Error Resume Next
    Set wb = Nothing
    Set sh = Nothing
    Set rng = Nothing
    Set cc = Nothing
End Sub

Sub ResetColors()
    If Not IsArray(cArr) Then
        MsgBox "No colored cells are saved. Cannot restore them."
        Exit Sub
    End If
    On Error Resume Next
    
    Dim wb As Workbook
    Set wb = ThisWorkbook
    Dim sh As Worksheet, sh2 As Worksheet
    Set sh = wb.ActiveSheet
    Dim rng As Range, cc As Range
    Set rng = sh.UsedRange
    
    Dim i As Long, j As Long
    
    With sh
        For i = LBound(cArr, 2) To UBound(cArr, 2)
            .Range(cArr(1, i)).Interior.Color = cArr(2, i)
        Next i
    End With
    Erase cArr
    Csaved = False
ep:
    On Error Resume Next
    Set wb = Nothing
    Set sh = Nothing
    Set rng = Nothing
    Set cc = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,639
Members
449,093
Latest member
Ahmad123098

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