+ Reply to Thread
Results 1 to 7 of 7

Automatic Page setup due to increase or decrease

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Automatic Page setup due to increase or decrease

    Hi,

    I am using a pivot table very frequently whose rows increase and sometimes decreases.Hence,I have to accordingly do the setup for pagebreak and has drag the fill handler towards the of end data available.

    How this can be resolved with vba.

    Thanx

  2. #2
    Forum Contributor
    Join Date
    09-14-2012
    Location
    mumbai,india
    MS-Off Ver
    Excel 2003
    Posts
    367

    Re: Automatic Page setup due to increase or decrease

    Please attachment sample your requirement

  3. #3
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Re: Automatic Page setup due to increase or decrease

    Pls find enclosed in attachment.Currently in PT Sheet which is infact Pivot table whose page setup is A1:B8.When the data increases or decreases in data sheet ,the page setup in PT Sheet which once set remains there only i.e A1:B8.So,I want it to be dynamic with the increase or decrease in rows.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    09-14-2012
    Location
    mumbai,india
    MS-Off Ver
    Excel 2003
    Posts
    367

    Re: Automatic Page setup due to increase or decrease

    Sorry for the late reply I was very busy.
    Try this
    Sub Tester()
        Dim rng As Range, dict As Object
        With Sheets("Data").Activate
    
        Set rng = Range(Range("A2"), Cells(Rows.Count, 1).End(xlUp)).Resize(, 3)
    
        Set dict = SubTotals(rng, 1, 3)
        
        DumpDict dict, Sheets("PT").Range("C4")
        Sheets("PT").Activate
    End With
    End Sub
    
    Function SubTotals(rng As Range, colKey As Long, colVal As Long) As Object
        Dim rv As Object, rw As Range, k, v
        Set rv = CreateObject("scripting.dictionary")
        For Each rw In rng.Rows
            k = rw.Cells(colKey).Value
            v = rw.Cells(colVal).Value
            If Not IsError(k) And Not IsError(v) Then
                If Len(k) > 0 And IsNumeric(v) Then
                    rv(k) = rv(k) + v
                End If
            End If
        Next rw
        Set SubTotals = rv
    End Function
    
    Sub DumpDict(dict As Object, rng As Range)
        Dim i As Long, k
        i = 0
        For Each k In dict.keys
            With rng.Cells(1)
                .Offset(i, 0).Value = k
                .Offset(i, 1).Value = dict(k)
            End With
            i = i + 1
        Next
    End Sub

  5. #5
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Re: Automatic Page setup due to increase or decrease

    Hi,
    Its not working.I have used your code but when I increase the data the pagebreak does not changes.

    Kindly see what is missing in the code.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    09-14-2012
    Location
    mumbai,india
    MS-Off Ver
    Excel 2003
    Posts
    367

    Re: Automatic Page setup due to increase or decrease

    Try this attachment file.
    Attached Files Attached Files
    Last edited by sanju2323; 03-17-2016 at 01:42 AM.

  7. #7
    Forum Contributor
    Join Date
    03-11-2011
    Location
    Nepal
    MS-Off Ver
    MS Excel 2024
    Posts
    1,384

    Re: Automatic Page setup due to increase or decrease

    Ok this now perhaps work.If possible can you mentioned the comment in each line of code you have mentioned for my reference.

    I am marking this thread as solved.

    Last but not least, can u make a pivot table with two different sheets based on condition which I have posted in a thread at >>http://www.excelforum.com/showthread...t=#post4339025

    Thanx for your kind support.
    Last edited by paradise2sr; 03-17-2016 at 04:41 AM.

+ 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. Percentage Increase/Decrease
    By SathishKumar in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-16-2013, 10:52 AM
  2. Replies: 3
    Last Post: 09-18-2012, 01:01 AM
  3. Increase/Decrease
    By mifzal.mufthi in forum Excel General
    Replies: 4
    Last Post: 08-10-2012, 04:19 AM
  4. Automatic Increase/Decrease in Row Height and Column Width in cells
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-23-2010, 02:39 PM
  5. How to decrease margins/increase print area on page
    By Excelhelpfordebbie in forum Excel General
    Replies: 0
    Last Post: 07-15-2010, 09:45 PM
  6. % Increase and decrease.
    By DODGE in forum Excel General
    Replies: 5
    Last Post: 03-02-2010, 05:01 PM
  7. [SOLVED] % of increase or decrease
    By Neil R in forum Excel General
    Replies: 9
    Last Post: 11-26-2005, 11:15 PM
  8. [SOLVED] How do I set a cell that can increase but never decrease?
    By Rich in forum Excel General
    Replies: 1
    Last Post: 11-02-2005, 06:17 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