palaeontology
Active Member
- Joined
- May 12, 2017
- Messages
- 444
- Office Version
- 2016
- Platform
- Windows
Hi,
I have a UserForm with a command button that, when pressed, causes page 1 and 2 of any worksheet named with a 5-digit number (eg: 76349) to be printed.
However, before the act of printing, I'd like the range of cells P22:U22 to have their font colour changed to white and any fill colour that might be in one or more of the cells to also be change to white so nothing in those cells will appear in the print.
I don't know if it's important, but some of the cells in that range are merged. Does that make a difference to the code ?
NOTE: After the sheet is printed, the sheet is deleted using an different code, so the font and fill colour does not need to be returned to their former colours.
Is someone able to tell me how to amend my current code to allow for this ?
I have a UserForm with a command button that, when pressed, causes page 1 and 2 of any worksheet named with a 5-digit number (eg: 76349) to be printed.
Code:
For Each ws In ThisWorkbook.Worksheets
If ws.Name Like "#####" Then
ws.PageSetup.Orientation = xlLandscape
ws.PrintOut From:=1, To:=1
ws.PageSetup.Orientation = xlLandscape
ws.PrintOut From:=2, To:=2
End If
Next ws
However, before the act of printing, I'd like the range of cells P22:U22 to have their font colour changed to white and any fill colour that might be in one or more of the cells to also be change to white so nothing in those cells will appear in the print.
I don't know if it's important, but some of the cells in that range are merged. Does that make a difference to the code ?
NOTE: After the sheet is printed, the sheet is deleted using an different code, so the font and fill colour does not need to be returned to their former colours.
Is someone able to tell me how to amend my current code to allow for this ?
Last edited: