ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to format the print? (https://www.excelbanter.com/excel-programming/382873-how-format-print.html)

[email protected]

how to format the print?
 
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

how to format the print?
 
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

[email protected]

how to format the print?
 
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

how to format the print?
 
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


All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com