![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 128
|
I've created a Macro which runs through an old worksheet, copies most of the data and pastes into a new worksheet where it is then reformatted. The last thing I need to do is set the page breaks so that the worksheet is only one page wide (it can be an indefinite number of pages long). I have used the following code to achieve this:
With ActiveSheet.PageSetup .AdjustTo = False .FitToPagesWide = 1 .FitToPagesTall = False .FitTo = True End With This works at setting the Fit To section of the Page set up to 1 by blank but the radio button stays in the Adjust To part. It's not that the worksheet is just too wide for this to work since it is only three columns and when I manually set it to one page by blank it works fine. For some reason it just insists on leaving the page break after the second column. I've even tried the following code which doesn't seem to have any effect at all on the worksheet: ActiveSheet.VPageBreaks(1)DragOff Direction:=xlToRight, RegionIndex:=1 ActiveSheet.VPageBreaks(1).Location = ActiveSheet.Range("c5") All of this is simply an attempt to make one page wide which includes only columns A, B, and C. Any ideas? |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try the following code:
With ActiveSheet.PageSetup .PrintArea = "$A:$C" .FitToPagesWide = 1 .FitToPagesTall = False End With The code sets the print area to columns A:C and set the page wide to 1.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Location: Holland
Posts: 8
|
Does it help to ADD to your code for the
pagesetup: .PageSetup.Zoom=False |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Posts: 128
|
Thanks guys! Adding both the Print Area and setting the Zoom to False finally set my page breaks right.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|