• Using Subtotal levels in code (2000 SR-1)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Using Subtotal levels in code (2000 SR-1)

    Author
    Topic
    #394708

    Hi All! smile

    I’m hoping someone can help me… I’ve been working on creating a different way of allocating interest inventory for my company… It took a long time but I’ve finally got the old way to tie in to the new way…
    Yahoo!!! I’m balanced!!! groovin

    What I need from you is to know if… I have added 2 or more levels of Subtotals on a sheet… By Currency, then Dept, etc… and another sheet with different levels of Subtotals… Can I, in code, create a new table on a third sheet that uses the different subtotal levels to compare/balance…

    What I mean is… I hit the button I created and code runs that drags in the records I want and then adds the levels of subtotals…
    Now I’d like to go to a third sheet and list the currencies, depts, etc, and bring in subtotal data from the other sheets to compare and show balanced…

    In code can I say something like…
    Find Sheet1’s Canadian Currency section, Dept 001’s Total and put it here… Next to it put Sheet2’s Canadian Currency section Dept 001’s Total… etc…

    I’m sorry… I don’t think I’m making sense…. laugh

    Okay… Let’s try this… The code below makes the subtotals after the new data is updated… (It works, but please feel free to edit this if I’m doing something silly…)

    Range(“A2”).Select
    Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(5, 6, 7, 8, 9, 10), _
    Replace:=False, PageBreaks:=False, SummaryBelowData:=True
    Range(“B2”).Select
    Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(5, 6, 7, 8, 9, 10), _
    Replace:=False, PageBreaks:=False, SummaryBelowData:=True

    Can I now use something like Sheet3, Cell(whatever) = Selection.Subtotal Group1?… or do I have to search for the lines with the words “Dept 001 Total”, etc and offset to the right column?

    thankyou in Advance for any ideas!!!

    Viewing 2 reply threads
    Author
    Replies
    • #725852

      Normally I’m against posting a workbook with the problem at hand, but in this case:

      Could you post a small sample workbook with bogus information that is already set up the way you would like it (that is, the end result and some explanation)?

      • #725935

        Thanks Jan… I’ll try put something together for an example…

        The workbook has about 20 sheets with countless named ranges referring to one another, so at the moment I’m not sure where to begin the explanation…
        By the way, I didn’t create this mess… I’m just the person responsible for making changes before year end…
        Personally I’d rather take the whole thing, scrap it, and do the work in a normalized database… The problem there is that I don’t have the time…

        Anyway… I’ll post back when I have something to show you….

        • #725960

          [indent]


          countless named ranges


          [/indent]

          RUN to “The Excel MVP page” listed below and download my Name Manager.

          • #725976

            Thanks again Jan! I downloaded and installed the Name Manager…
            There are 1808 named ranges in this workbook…

            drop Somebody kill me now!!

            • #726398

              [indent]


              1808 named ranges


              [/indent]
              Wow.

              You might try to get rid of names not in use.

              – Make a backup copy of the book.
              – Then you could try filtering using the Unused names checkbox (go get a cup of coffee after checking it, it’ll take a while).
              – Select all the now left over names (first click the Multi button, then drag accross the names list) and press delete.
              – Now check the book for any #Name! errors. Especially check all objects (charts, pivot tables, conditional formatting, etcetera). If any got messed up, reload the backup copy.

            • #726399

              [indent]


              1808 named ranges


              [/indent]
              Wow.

              You might try to get rid of names not in use.

              – Make a backup copy of the book.
              – Then you could try filtering using the Unused names checkbox (go get a cup of coffee after checking it, it’ll take a while).
              – Select all the now left over names (first click the Multi button, then drag accross the names list) and press delete.
              – Now check the book for any #Name! errors. Especially check all objects (charts, pivot tables, conditional formatting, etcetera). If any got messed up, reload the backup copy.

          • #725977

            Thanks again Jan! I downloaded and installed the Name Manager…
            There are 1808 named ranges in this workbook…

            drop Somebody kill me now!!

        • #725961

          [indent]


          countless named ranges


          [/indent]

          RUN to “The Excel MVP page” listed below and download my Name Manager.

      • #725936

        Thanks Jan… I’ll try put something together for an example…

        The workbook has about 20 sheets with countless named ranges referring to one another, so at the moment I’m not sure where to begin the explanation…
        By the way, I didn’t create this mess… I’m just the person responsible for making changes before year end…
        Personally I’d rather take the whole thing, scrap it, and do the work in a normalized database… The problem there is that I don’t have the time…

        Anyway… I’ll post back when I have something to show you….

    • #725927

      If I understand what you are asking (and I admit, I am a little confused):
      I think you can do what you want, by NOT even doing any subtotaling and grouping or a macro.
      You should be able to do it DIRECTLY from your data with a pivot table report.
      Pivot table will extract out a summary of the data, by the various sections (ROW field) or section by section (PAGE field) depending on how you set it up.

      Data-pivot table report gets you the wizard.
      Once you create the privot table, you can right click on it to refresh the table (with new “raw data” added) or to modify the layout.

      If I do NOT understand, I also second Jan’s suggestion to provide a simple example with more detailed explanation of what you would like, perhaps an example “output table” that you want to generate from the raw table.

      Steve

    • #725928

      If I understand what you are asking (and I admit, I am a little confused):
      I think you can do what you want, by NOT even doing any subtotaling and grouping or a macro.
      You should be able to do it DIRECTLY from your data with a pivot table report.
      Pivot table will extract out a summary of the data, by the various sections (ROW field) or section by section (PAGE field) depending on how you set it up.

      Data-pivot table report gets you the wizard.
      Once you create the privot table, you can right click on it to refresh the table (with new “raw data” added) or to modify the layout.

      If I do NOT understand, I also second Jan’s suggestion to provide a simple example with more detailed explanation of what you would like, perhaps an example “output table” that you want to generate from the raw table.

      Steve

    Viewing 2 reply threads
    Reply To: Using Subtotal levels in code (2000 SR-1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: