+ Reply to Thread
Results 1 to 9 of 9

Inserting Pages

  1. #1
    Registered User
    Join Date
    09-12-2019
    Location
    Australia
    MS-Off Ver
    Office 365 Business
    Posts
    7

    Inserting Pages

    Hi,

    I'm looking to add a form control button to a excel quote letter that allows me to add an additional page. See attached sample (with most information removed) showing the layout.

    Essentially using the button would copy rows 1-49 of the Data Worksheet & insert them above row 101 of the Quote worksheet. This is easy enough to accomplish, however where I am stuck is that if any additional pages needs to be added. Using the same button will insert the same copied rows at the same point, however as there is now an additional page, this enters the data at the wrong point, it would need to insert the rows directly above row 150. This will continue for every page added.The macro cell reference for the new page will need to update every time a page is added. The Quote (2) worksheet shows the desired result of using the button. Can someone help me with VBA code for this?

    An additional problem I'm encountering is that every time a new page is added, the page break moves by 1 row. If this could be changed too it would be great.

    Thanks in advance, let me know if you need me to clarify anything.
    Attached Files Attached Files
    Last edited by tomsay20; 09-13-2019 at 09:40 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Inserting Pages

    Hi
    Try
    Please Login or Register  to view this content.
    If you like it we may refine it
    Good luck

  3. #3
    Registered User
    Join Date
    09-12-2019
    Location
    Australia
    MS-Off Ver
    Office 365 Business
    Posts
    7

    Re: Inserting Pages

    Quote Originally Posted by mohadin View Post
    Hi
    Try
    Please Login or Register  to view this content.
    If you like it we may refine it
    Good luck
    Thanks Mohadin! That works almost perfectly. The only issue still remaining is that when the macro is used, the page breaks move & have to be adjusted manually. Could you amend the code to fix this?

    Your help is much appreciated!!

  4. #4
    Registered User
    Join Date
    09-12-2019
    Location
    Australia
    MS-Off Ver
    Office 365 Business
    Posts
    7

    Re: Inserting Pages

    Hi Mohadin,

    I've fixed the page break issue with the following added to your code :

    Dim x As Integer
    Dim LR As Integer
    LR = Cells(Rows.Count, 2).End(xlUp).Row
    For x = 2 To LR
    If Cells(x, 2).Value = "CELL VALUE" Then
    ActiveSheet.HPageBreaks.Add Before:=Rows(x + 1)
    End If
    Next
    End Sub

    I also need a macro to be able to delete a page, this deleted portion would be equal to the last added page. However, this would need to be restricted to not allow deleting more content was available in the original quote letter. For instance if 2 pages had been added using your code above, then only a maximum of 2 pages could be deleted with the new code.

    Do you know how to achieve this?

  5. #5
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Inserting Pages

    Hi
    I also need a macro to be able to delete a page, this deleted portion would be equal to the last added page. However, this would need to be restricted to not allow deleting more content was available in the original quote letter. For instance if 2 pages had been added using your code above, then only a maximum of 2 pages could be deleted with the new code.
    To be honest with you it is not clear to me

  6. #6
    Registered User
    Join Date
    09-12-2019
    Location
    Australia
    MS-Off Ver
    Office 365 Business
    Posts
    7

    Re: Inserting Pages

    Essentially I want code to reverse the macro you provided me before. Then I will have an option to add & remove pages from the spreadsheet.

  7. #7
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Inserting Pages

    Like this
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-12-2019
    Location
    Australia
    MS-Off Ver
    Office 365 Business
    Posts
    7

    Re: Inserting Pages

    Thanks Mohadin,

    With a little tweaking this is working great. Much appreciated!!

  9. #9
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Inserting Pages

    you are well come
    Thank you for the feed back

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need vba code to print specific pages or all pages in a multipage UserForm
    By Pimp_mentality in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-24-2020, 08:13 PM
  2. Replies: 4
    Last Post: 10-15-2015, 04:28 PM
  3. Inserting Rows On Multiple Pages
    By Trintrin in forum Excel General
    Replies: 3
    Last Post: 01-15-2013, 03:09 PM
  4. Replies: 1
    Last Post: 12-05-2012, 05:30 AM
  5. [SOLVED] Inserting a row on multiple pages
    By Gideonis in forum Excel General
    Replies: 2
    Last Post: 04-11-2012, 09:09 PM
  6. Inserting rows, auto add to other pages?
    By milehighpgmr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2010, 12:54 PM
  7. Replies: 2
    Last Post: 12-30-2005, 12:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1