Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If there's only one sheet in the workbook that is ever printed, you could use
code like this--it goes behind the ThisWorkbook module. Option Explicit Private Sub Workbook_BeforePrint(Cancel As Boolean) Cancel = True With Worksheets("sheet1") .Range("C1").EntireColumn.Hidden = True Application.EnableEvents = False .PrintOut preview:=True Application.EnableEvents = True .Range("C1").EntireColumn.Hidden = False End With End Sub But if there's more than one sheet to be printed, this won't work. In fact, there are so many ways to print (group sheets or entire workbook) that I don't think there is a safe way to do this. I still think using a dedicated macro is the best way. wrote: Thank you for your good trick, it works! But another questions, in this way, to print means to call the Macro, but someone would quit don't like it, they just want to click the traditional "print" button and everything works, any ideas to write such VBA codes for the print function? Thank you again. Dave Peterson wrote: Record a macro when you hide column C, then print, then show column C and you'll have the code. wrote: If a Excel data sheet have data in colomns A, B, C and D, and some one wants to print these data, but he doesn't want to print the data for example in colomn C, how to use VBA to realize this? -- Dave Peterson -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
After print preview it changes the format, what could it be? | Excel Discussion (Misc queries) | |||
How to format the extension less file to print with Dos's Print Command | Excel Discussion (Misc queries) | |||
Print Format | Excel Programming | |||
Auto format a workbook to Print | Excel Programming | |||
worksheet print format | Excel Worksheet Functions |