Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Print Macro code help

Hi

I have recorded a macro to hide certain columns on my sheet, then to print
the sheet and then unhide the columns. The code looks ok, but when it prints
I am only getting 2 columns instead of the whole document. Any help
gratefully received, macro code below. Thanks

Private Sub CommandButton3_Click()
'
' print_mode Macro
' Macro recorded 02/09/2008 by Leigh Douglass'

'
Columns("B:B").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll ToRight:=1
Columns("M:N").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll ToRight:=3
Columns("P:AF").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll ToRight:=-9
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Columns("A:C").Select
Range("C1").Activate
Selection.EntireColumn.Hidden = False
ActiveWindow.SmallScroll ToRight:=4
Columns("L:O").Select
Range("O1").Activate
Selection.EntireColumn.Hidden = False
ActiveWindow.SmallScroll ToRight:=3
Columns("O:AG").Select
Range("AG1").Activate
Selection.EntireColumn.Hidden = False
Range("A1").Select
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Print Macro code help

hi
i noticed in your recorded macro that you didn't reset the print area.
hiding column(and rows) doesn't reset the print area. you need to add a line
to set this.

ActiveSheet.PageSetup.PrintArea = "$A$1:$AG$40" 'change to suit

also.
recording a macro records all of you mouse and keyboard actions, most of
which are usually not needed. in your macro you have alot of selecting and
scrolling which is not needed and could be reduced to.....

Columns("B:B").EntireColumn.Hidden = True
Columns("M:N").EntireColumn.Hidden = True
Columns("P:AF").EntireColumn.Hidden = True

and

Columns("B:B").EntireColumn.Hidden = False
Columns("M:N").EntireColumn.Hidden = False
Columns("P:AF").EntireColumn.Hidden = False

regards
FSt1

"Leigh Douglass" wrote:

Hi

I have recorded a macro to hide certain columns on my sheet, then to print
the sheet and then unhide the columns. The code looks ok, but when it prints
I am only getting 2 columns instead of the whole document. Any help
gratefully received, macro code below. Thanks

Private Sub CommandButton3_Click()
'
' print_mode Macro
' Macro recorded 02/09/2008 by Leigh Douglass'

'
Columns("B:B").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll ToRight:=1
Columns("M:N").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll ToRight:=3
Columns("P:AF").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll ToRight:=-9
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Columns("A:C").Select
Range("C1").Activate
Selection.EntireColumn.Hidden = False
ActiveWindow.SmallScroll ToRight:=4
Columns("L:O").Select
Range("O1").Activate
Selection.EntireColumn.Hidden = False
ActiveWindow.SmallScroll ToRight:=3
Columns("O:AG").Select
Range("AG1").Activate
Selection.EntireColumn.Hidden = False
Range("A1").Select
End Sub

Reply
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
A macro code to print multiple sheets in different w.books Gladiator Excel Discussion (Misc queries) 3 February 22nd 10 07:49 PM
can anyone help with the code for creating a aut print macro... des-sa[_2_] Excel Discussion (Misc queries) 1 May 17th 08 01:01 PM
Differentiate between 'Print' and 'Print Preview' in VBA code Mattantaliss Excel Programming 4 April 17th 06 09:31 PM
Macro 'Code execution has been interupted' error after print? Bluehair the Pirate Excel Programming 1 February 9th 06 06:19 PM
Code before Print but not Print Preview widemonk Excel Programming 1 November 14th 05 01:48 PM


All times are GMT +1. The time now is 06:33 PM.

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"