![excel hide columns when printing excel hide columns when printing](https://cdn.extendoffice.com/images/stories/doc-excel/hide-unused-cell/doc-hide-unused-cell-02.png)
Even though it is white-on-white, it is still there, and can be copied/pasted out of the PDF file. If you're trying to hide sensitive information, know that if you print to PDF, the data will still be present in the PDF file. Setting text to white on white: Could work in some cases, but BEWARE it does not prevent the hidden data from leaking. For example, if I have a spreadsheet with columns A-E, and I want to hide columns B and D on printing, then it puts each printed column on a separate page. Or, perhaps it handles it very well, but the selected approach doesn't work in my case. Setting print area: This can work depending on the layout of the sheet, but it doesn't handle a non-contiguous print area selection too well. I had the same or similar need, and there are pros and cons to various approaches. I don't have enough reputation points to comment on other posts, so I'll add an "answer" with some observations. Hide rows, columns or cells when you print a sheet.Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = False Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True Or hide all rows with a blank cell in column A: With ActiveSheet Range("B1,D1").EntireColumn.Hidden = False Range("B1,D1").EntireColumn.Hidden = True Or change the respective part to hide columns (this example hides columns B and D): With ActiveSheet To hide the columns or rows, do the printout, and then unhide them.Įxample: Private Sub Workbook_BeforePrint(Cancel As Boolean)
![excel hide columns when printing excel hide columns when printing](https://cdn.ablebits.com/_img-blog/hide-columns/excel-hide-columns-option.png)
#Excel hide columns when printing code#
Use the function in the code editor (VBA): Private Sub Workbook_BeforePrint(Cancel As Boolean) When I needed to do what you're saying, what I would do is: This is under “Shape Options” → “Size & Properties” → “Properties”.) (by clearing the “Print object” checkbox). Under Properties, you can select if the shape is printed or not Right click on the shape and select “Format Shape”.If you do that, the formula ( =D15) will display literally. Configure the shape to display the content of the desired cell,īy selecting the shape and then typing a reference (e.g., =D15).Or no fill to let the underlying cell’s fill color show through Set the fill color to whatever you want for the background color, Position it over the cell where you want the data to appear.įormat it visually as you want. In that case, for each cell that that you want to display but not print: If that’s good enough for you, you’re done.īut you might want the excluded cell(s) to appear inside the print area Put the cell(s) that you don’t want to print outside the print area. It builds on the idea of using a “Print Area”, This solution doesn’t require you to take special actionīefore and after each time you need to print the file.