LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
After print preview it changes the format, what could it be? The Evaluator Excel Discussion (Misc queries) 3 December 3rd 08 09:55 PM
How to format the extension less file to print with Dos's Print Command Badshah Excel Discussion (Misc queries) 0 November 28th 06 12:44 PM
Print Format Eugene[_8_] Excel Programming 0 June 27th 06 08:01 PM
Auto format a workbook to Print Curt Excel Programming 1 January 3rd 06 02:34 PM
worksheet print format mark kubicki Excel Worksheet Functions 2 September 30th 05 07:41 PM


All times are GMT +1. The time now is 04:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"