A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

hide columns before printing



 
 
Thread Tools Display Modes
  #1  
Old April 15th, 2010, 07:24 AM posted to microsoft.public.excel.misc
Jean-Paul De Winter
external usenet poster
 
Posts: 26
Default hide columns before printing

Hi,

Before actually printing my sheet I want to hide column A and B.
Can I do this automatically without having to hide them manually?

Thanks

--

Mvg.
Jean-Paul De Winter


  #2  
Old April 15th, 2010, 08:02 AM posted to microsoft.public.excel.misc
Jarek Kujawa[_2_]
external usenet poster
 
Posts: 775
Default hide columns before printing

press ALT+F11 to get to VBA
then in Project-VBA Project window double click on ThisWorkbook
put this code into the window to the right:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Range("A:B").Columns.Entirecolumn.Hidden = True
End Sub


HIH
pls click YES if it helped


On 15 Kwi, 08:24, "Jean-Paul De Winter"
wrote:
Hi,

Before actually printing my sheet I want to hide column A and B.
Can I do this automatically without having to hide them manually?

Thanks

--

Mvg.
Jean-Paul De Winter


  #3  
Old April 15th, 2010, 09:40 AM posted to microsoft.public.excel.misc
ozgrid.com
external usenet poster
 
Posts: 328
Default hide columns before printing

Define a Custom View.


--
Regards
Dave Hawley
www.ozgrid.com
"Jean-Paul De Winter" wrote in message
...
Hi,

Before actually printing my sheet I want to hide column A and B.
Can I do this automatically without having to hide them manually?

Thanks

--

Mvg.
Jean-Paul De Winter



  #4  
Old April 15th, 2010, 11:54 AM posted to microsoft.public.excel.misc
Jean-Paul
external usenet poster
 
Posts: 74
Default hide columns before printing

???

ozgrid.com wrote:
Define a Custom View.


  #5  
Old April 16th, 2010, 03:19 AM posted to microsoft.public.excel.misc
ozgrid.com
external usenet poster
 
Posts: 328
Default hide columns before printing

Read your Excel Help on "Custom Views"


--
Regards
Dave Hawley
www.ozgrid.com
"Jean-Paul" wrote in message
...
???

ozgrid.com wrote:
Define a Custom View.

  #6  
Old April 16th, 2010, 11:35 PM posted to microsoft.public.excel.misc
Jean-Paul
external usenet poster
 
Posts: 74
Default hide columns before printing

Hi,

Thanks for the code, it works, but, after printing and returning to the
worksheet, both columns remain hidden..
How can I automatically make them visible again??

Thanks

Jarek Kujawa wrote:
press ALT+F11 to get to VBA
then in Project-VBA Project window double click on ThisWorkbook
put this code into the window to the right:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Range("A:B").Columns.Entirecolumn.Hidden = True
End Sub


HIH
pls click YES if it helped


On 15 Kwi, 08:24, "Jean-Paul De Winter"
wrote:
Hi,

Before actually printing my sheet I want to hide column A and B.
Can I do this automatically without having to hide them manually?

Thanks

--

Mvg.
Jean-Paul De Winter


  #7  
Old April 21st, 2010, 11:22 AM posted to microsoft.public.excel.misc
Jarek Kujawa[_2_]
external usenet poster
 
Posts: 775
Default hide columns before printing

Jean_Paul's and Dave's solution is better

but if you prefer to stick with VBA then you might use this one (which
is far from perfect):

Sub Makro1()

For i = 1 To ActiveWindow.SelectedSheets.Count
names_string= names_string & Sheets(i).Name
Next i

If names_string Like "*Sheet1*" Then Arkusz1.Columns("A:B").Hidden =
True

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

If names_string Like "*Sheet1*" Then Arkusz1.Columns("A:B").Hidden =
False

End Sub

adjust your sheet names and columns

On 17 Kwi, 00:35, Jean-Paul wrote:
Hi,

Thanks for the code, it works, but, after printing and returning to the
worksheet, both columns remain hidden..
How can I automatically make them visible again??

Thanks



Jarek Kujawa wrote:
press ALT+F11 to get to VBA
then in Project-VBA Project window double click on ThisWorkbook
put this code into the window to the right:


Private Sub Workbook_BeforePrint(Cancel As Boolean)
* * *Range("A:B").Columns.Entirecolumn.Hidden = True
End Sub


HIH
pls click YES if it helped


On 15 Kwi, 08:24, "Jean-Paul De Winter"
wrote:
Hi,


Before actually printing my sheet I want to hide column A and B.
Can I do this automatically without having to hide them manually?


Thanks


--


Mvg.
Jean-Paul De Winter- Ukryj cytowany tekst -


- Pokaż cytowany tekst -


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.