Macro to print and change font color

gordonc068

New Member
Joined
Feb 8, 2016
Messages
12
All,

I am building a new hire form in excel and for audit purposes when we print certain information needs to be redacted. The best way I've come up with so far is to make a macro that will:
1. select the cells I want to change
2. change font color to the same as the background
3. print active sheet
4. select the same cells
5. change font color back to black

I tried to record such a marco but it isn't capturing the print portion of the cycle. Do you either; have a way for the recorder to pick up the print action or, write a macro with those items?

The below is what was recorded, note the lack of a print action. To print I went to file and chose print, is there a different way that it would pick up?

Sub Macro4()
'
' Macro4 Macro
'


'
Range("C10:C14,G9").Select
Range("G9").Activate
With Selection.Font
.Color = -52
.TintAndShade = 0
End With
Range("C10:C14,G9").Select
Range("G9").Activate
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
Range("D10").Select
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hey, try this (I dont even own a printer, so its untested haha)

Code:
Sub Macro4()

    With Range("C10:C14,G9").Font
        .Color = -52
        .TintAndShade = 0
    End With
ActiveSheet.PrintOut
    With Range("C10:C14,G9").Font
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    End Sub

Julian
 
Upvote 0

Forum statistics

Threads
1,217,292
Messages
6,135,673
Members
449,956
Latest member
nibor

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