Macro To Save Sheet With Same Page Breaks As Original

May 14, 2009

I am trying to sort a macro out to save my sheet the same as the original when the button is clicked. When i try it from one location it is fine but from another location i get a print error, the error says prit quality is not right, when i debug it highlights: Print Quality = 600 I have tried changing it but keep getting the same error. Their maybe an easier way to do this but not being very good on VB i dont know what to do. This file is on a server and will be accessed from different locations.

View 2 Replies


ADVERTISEMENT

Macro: Clear Page Breaks & Add Page Breaks

Nov 28, 2006

I need to remove all existing page breaks in a document and add a page break every 72 rows. I've tried some similar codes from this forum with other functions that I don't need in it.

View 7 Replies View Related

Save As PDF And Page Breaks

Oct 13, 2011

For some reason, when I 'Print Preview' an excel file, it puts the page breaks in one place.

However, when I save it as a PDF, it moves them slightly, meaning that not as much fits on one page.

View 2 Replies View Related

Set Page Breaks Based On Cell Value On Protected Sheet

Mar 1, 2008

I'm not sure went wrong but my code was working fine until I protected the worksheet. Then I made some changes to the code by adding code to unprotect the sheet before running the code and then protecting it again when complete. That didn't work. I unprotected the sheet and ran the code again and now I'm getting a Run Time Error and the code stops when it attempts to set the Page Breaks which was previously fine. Because the data I use to generate this report is based on data from another report that does not need to recalculate before running. I have a Worksheet Activate Private Sub that sets the Application Calculation to Manual. When the sheet is deactivated it sets it back to Automatic. Hence the line in the following code to calculate this worksheet. When attempting to debug the line that highlights is the first line that attempts to set the page break that corresponds to the matching location criteria from cell A2.

Private Sub Worksheet_Change(ByVal Target As Range)
Application. ScreenUpdating = False
Application.EnableEvents = False
ActiveSheet.ResetAllPageBreaks
Range("A24").Value = Range("A1")
Range("A25").Value = Range("A2")
Range("A26").Value = Range("A3")
Range("A27").Value = Range("A4")
Range("A28").Value = Range("A5")
Range("A29").Value = Range("A6")
Range("A30").Value = Range("A7")
Range("A31").Value = Range("A8")
Range("A32").Value = Range("A9")
Range("A33").Value = Range("A10")...................

View 4 Replies View Related

Macro - Page Breaks/printing

Mar 20, 2009

is there a macro code that will autmatically determine the end of your page and adjust your page breaks accordingly?

View 9 Replies View Related

Dynamically Set Print Area And Page Breaks On Large Sheet?

Feb 28, 2012

I am trying to dynamically set my print area and page breaks on a large sheet.

Basically I want to get the last column and last row in used in the sheet. And to create boxes (24x30) until I get all the way horizontally and vertically.

View 2 Replies View Related

XL4 Print Macro. Count Page Breaks

Sep 21, 2007

I'm using a procedure (PageSetupXL4M) which uses the XL4 Page.Setup function to format a sheet in VBA--since it's much faster than VBA's current PageSetup function. (It's explained here: [url]

The problem is that the XL4 Page.Setup function seems to clear all the automatic page breaks. I'll use "MsgBox Sheets(1).HPageBreaks.Count" to display the page break count both before and after the XL4 function. It'll show the correct # of PageBreaks before the function, but shows 0 after.

I need to return the correct # of PageBreaks AFTER the function is run because the formatting of the page can sometimes alter the number of PageBreaks.

how to get "HPageBreaks.Count" to recalculate and return the correct number of breaks?

View 6 Replies View Related

Return To Original Page, Cell After Macro

Nov 5, 2009

I have a workbook with 7 sheets. Each sheet has about 9 different macro buttons that are repeated all over the sheet in various locations. I want to return automatically to the sheet and cell that was last active before running a macro.

View 2 Replies View Related

VBA Macro To Insert Horizontal Page Breaks Based On Criteria Of 1 Column

Jan 10, 2010

I want to achieve is a procedure that inserts horizontal page breaks at certain parts of the sheet where there is a cell equal to 2. Here is the code I have so far.

Sub insert_pagebreak()
Dim printbreak_cell As Range
Dim j As Long
Dim i As Long
ActiveSheet.ResetAllPageBreaks
Set printbreak_cell = Range("AD1")
j = 1
For i = 1 To 100
If printbreak_cell.Value = 2 Then
Set ActiveSheet.HPageBreaks(j).Location = printbreak_cell
j = j + 1
End If
Set printbreak_cell = printbreak_cell.Offset(1, 0)
Next i
End Sub

Everything works until the cell value reaches a 2, and then once it goes into the If statement I get a 'Application-defined or object-defined error' at the below line.

Set ActiveSheet.HPageBreaks(j).Location = printbreak_cell.............

View 3 Replies View Related

Can't Move Page Breaks In Page Break Preview

Mar 26, 2006

I suddenly can't adjust my page breaks in any Excel spreadsheet while in Page Break Preview. Is there some option to turn it on and off?

View 7 Replies View Related

SaveAs - Copy Sheet Into New Workbook And Save It In Same Folder As Original Workbook

Jun 17, 2014

I have been trying to edit a code which previously saved a copy in a new workbook to a specific folder/path. (Additionally it copies and clears some figures, but this is working as it should.)

However I would like the copy to be saved at the same location as the original workbook, regardless of the path the original workbook is saved.

I.e if I need to move the workbook containing the code to a new folder/location, when using the macro, the new copy should be stored in the same folder/location as the original one.

For now it is only saving the copy into "My Documents"

Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 16-02-2009 by ceng
'

Sheets("Bunker ROB").Select
Sheets("Bunker ROB").Copy
ActiveWorkbook.SaveAs Filename:= _
ActiveWorkbook.Path & Range("D3"), _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

[Code] ........

View 2 Replies View Related

Page Breaks When Value Changes

Aug 13, 2009

I want some code which will automatically insert a page break every time the data changes in a column. In column B- the data is structured as below;

DOG
<blank cell>
<blank cell>
DOG
<blank cell>
DOG
<blank cell>
<blank cell>
CAT
<blank cell>
CAT
<blank cell>
MOUSE
<blank cell>
MOUSE
MOUSE
<blank cell>

Etc

The code I want would insert the page break every time every time the data changed- but not where there is a blank cell. I hope this makes sense. I realise the blank cells complicate things- the blank cells separating the data cells are there because there is additional;data in columns C,D,E etc

View 14 Replies View Related

Page Breaks Every Nth Row

Oct 2, 2007

I have a worksheet with 760 names on it. The first row are headers, 2nd row on is the data. I need to break the data up into 25 rows a piece, excluding the headers. I am making rosters, so each roster would have twenty five names per sheet. Of course I know I will have a couple of names left over, but this would help with the bulk.

View 3 Replies View Related

Too Many Automatic Page Breaks

Sep 5, 2013

I have a spreadsheet that I need to print, but Excel automatically puts in an automatic page break every cell. I have tried all other solutions to this problem posted on this site (page setup, printer issues, etc).

Spreadsheet attached.Posted Version.xlsm

View 1 Replies View Related

Remove Any Page Breaks

Oct 25, 2007

I'm using the this code to print some info out of an existing worksheet and I'd like to force excel to remove all pagebreaks, as the last column or two is always printed onto another page. Does anyone know how to programatically remove pagebreaks?

View 12 Replies View Related

Setting Page Breaks

Dec 2, 2008

how to write code to set page breaks every 4th column, or in certain intervals. For rows I have a simple .FitToPagesTall = 1, but I'm looking for something more dynamic for the columns.

View 4 Replies View Related

Get Rows # By H Page Breaks!?

Jun 14, 2009

[Solved by Myself]

.ActiveSheet.HPageBreaks(1).location.row

View 2 Replies View Related

Inserting Page Breaks With VBA

Apr 23, 2013

I am having serious issues inserting page breaks using VBA. I have even taken code from the Microsoft website and it still crashes.

Code:
Sub InsertPageBreaks()

With Worksheets(1)
.HPageBreaks.Add.Range("F25")
.VPageBreaks.Add .Range("F25")

[Code] ......

View 2 Replies View Related

Filter Out Page Breaks

Apr 25, 2008

I'm importing a text document into excel, and I have these page breaks that start with a c in the leftmost space(no other lines start with a character in the 1st space) and 15 spaces underneath it are page headers. I'm trying to create a macro that scans the entire A column for any "C" in the 1st leftmost space, highlight and delete(move page up) that "c" and the 15 spaces following it. I want the macro to loop until it ends.

So far, this is what I got for selecting C:

Dim c
For Each c In Range("A1:A306").Cells
If Left(activecell.characters.value,1)="C" Then
c.Select

View 9 Replies View Related

Force Page Breaks In Vba?

Mar 19, 2007

want to specify page breaks and set print areas when running a macro. Appears to work sometimes, but then breaks (hard and soft) pop up on their own). Currently using something like this to specify a 2 page wide view...

ActiveSheet.PageSetup.PrintArea = "$A:$Z"
With ActiveSheet.PageSetup
.FitToPagesWide = 2
Set ActiveSheet.VPageBreaks(1).Location = Range("P1")
End With

Can I force breaks to be more absolute (more accurately)?

View 7 Replies View Related

Detecting Page Breaks

Mar 20, 2007

I want a macro to assess whether there's a page break before column P, if so, remove it and continue, if not... continue.

View 7 Replies View Related

Macro To Save Worksheet As New File Then Return To Original File

Mar 14, 2014

I have a macro which successully saves a worksheet as new file to another file path....(below)...but I can't figure out how to close this new file and return to the original file...

Dim myPath As String, fName As String
myPath = Sheets("Date").Range("C8").Text
fName = Sheets("Date").Range("C9").Text
Sheets("Sage CSV File").Copy
With ActiveWorkbook
.SaveAs Filename:=myPath & fName
End With'

View 2 Replies View Related

Row Height Specifically For Page Breaks

Nov 20, 2008

I have a spreadsheet that I use for work that I have set the row height specifically for page breaks. I use the top 3 rows on each page as a header with that page info.

If I update it at home, then email it to work, the row height has changed. No real problem, I just go in and adjust the row height. Then if I email it back to home from work, it does the same thing.

It's just this particular sheet that does it. All of the other sheets that I use always keep their row height properties intact when emailing.

View 10 Replies View Related

Add 2 Blank Rows After Page Breaks

Jul 12, 2014

I have a sheet that data is imported into that is normally no more than 300 rows. I need to insert 2 blank rows after each page break. My problem is the row height is not always the same when the data is imported. How to insert 2 blank rows after each page break using a macro.

View 3 Replies View Related

Create Conditional Page Breaks

Jul 8, 2006

I have the following code that I am using to create conditional page breaks. It works sporadically. It will work on the data I used when i set up the code. It will sometimes work on smaller amounts of data. It will sometimes insert the page breaks but then error out at line: ActiveSheet.HPageBreaks.Add Before:= Cells(row_index + 1, "D"). I do not understand this code entirely as a i am novice VB user. Once I get this code to work, I'd love to imrove it so that the page breaks ends when there is no data in last row or last column.

Sub PageBreak()
Dim lastrow As Long
Dim row_index As Long
lastrow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
For row_index = lastrow - 1 To 2 Step -1
If Cells(row_index, "D").Value <> "" Then
'insert page breaks ever time value in column D changes
If IsNumeric(Cells(row_index, "D").Value) Then
If Cells(row_index, "D").Value <> Cells(row_index + 1, "D").Value Then
ActiveSheet.HPageBreaks.Add Before:=Cells(row_index + 1, "D")
End If
End If
End If
Next

View 2 Replies View Related

Conditional Insert Of Page Breaks

Mar 20, 2007

I have a spreadsheet that is 7 columns wide and contains blocks of data. The data blocks vary in size typically between 3 and 12 rows. Between each block of data is a blank row (there are no blank rows within the data blocks). There may be up to 500 rows in the spreadsheet consisting of maybe 30 varying size blocks of data.

I am attempting to produce a Macro that will insert page breaks into the spreadsheet, the requirement being that non of the blocks of data are split across two pages. I would need to be able to input the available number of rows per page (to allow for headers and footers), the Macro would then need to count down that many rows, find the last blank line before that point and insert a page break. It would then need to count from the position of the inserted page break to determine where to place the next page break etc.

View 4 Replies View Related

Find Page Breaks Faster

Jul 21, 2007

I need to find row numbers of the horizontal page breaks on a sheet quickly. The only method I have found to do this is by using the HPageBreaks property, which is painfully slow.

Is there another way of doing this that's faster? Or some other manner of using HPageBreaks that improves its speed?

The scenario is that I have a macro which generates a list of items where each item is two rows long. If an item intersects a page break--one row is on one page and the 2nd row is on the next page--I want to insert a row so that the entire item is on the next page.

View 9 Replies View Related

Set Page Breaks Groups For X Conditions

Aug 6, 2008

I have a report that is generated that is broken down into 4 or 5 headers.

What I want is basically a way to manually add page breaks for 2 conditions:

*That no section starts at the end of one page and ends on the next; I want to just insert a page break before the section so it is all on the next page.

* That if the first section is more than a page long, that it inserts a new header saying 'section 1 continued..' basically.

I've been able to code it and it functions how I want. However, it takes about 20-30 seconds on a dual-core computer with 2gb of memory to insert these page breaks, so I thought I'd get some expert advice on where the slow-downs are and how I could go about tightening up the code to get it to run faster. (this subprocedure is #15 of 15 when generating the report, and the rest take between 2 and 5 seconds combined).

Sub Quote_Page_Breaks()
Dim financials_start_row As Integer, financials_start_page As Integer, financials_end_row As Integer, financials_end_page As Integer
Dim recommended_start_row As Integer, recommended_start_page As Integer, recommended_end_row As Integer, recommended_end_page As Integer
Dim standard_end_row As Integer, standard_end_page As Integer
Dim i As Integer, page_break() As Integer
Dim recommended As Boolean
On Error Resume Next

View 4 Replies View Related

Loop And Delete Ranges Between Page Breaks

May 14, 2013

I have a report that contains several rows of data. This data is separated by page breaks, so for example, there could be 1500 rows, separated into 90 pages by page breaks. Each range may have anywhere between 35 and 45 rows, but some of those rows may contain no data.

I would like to loop through the cells column A, look for a certain criteria, then delete the range around that certain cell that is contained within the page breaks.

I have code that will loop through the cells in column A. I also managed to create code that will delete a set range but since the ranges aren't always a uniform number of rows I need another fix.

View 8 Replies View Related

Load Page Breaks For A Range In Array

Jul 13, 2014

Is it possible to load the page breaks for a range into an array without looping. Just checking, because looping is taking about 20 seconds or so.

Doesn't Work.

[Code] .....

Works but takes a second

[Code] ......

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved