+ Reply to Thread
Results 1 to 9 of 9

Thread: Running total from mixed codes in Columns.

  1. #1
    Registered User
    Join Date
    07-27-2010
    Location
    New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    4

    Question Running total from mixed codes in Columns.

    Hi all,
    As per the attached spreadsheet (template only) we are doing our GST (GST = NZ's Goods & Services Tax (@12.5%)) on Excel. Alternative to the download we have shared a sheet on Google Docs at

    http://spreadsheets.google.com/ccc?k...llVmc&hl=en_GB

    We’re wondering if there is a formula we can insert, I guess in the codes column, that can keep a running total on the sheet of each code as its listed, ie 200 = $100, 310 = $400 and so on.

    This being so that at any given moment during the GST period we can see at a glance exactly what has been spent for code 310 to date.

    At the moment the only way we have managed to do this is by filtering the codes column for a particular code, then copying and pasting that info to a new sheet, & auto summing a total for it.

    As we also want to be able to print off a ‘ledger’ of sorts for each code, I have then been changing the layout slightly to create this. See page 2 in the template.

    Any help or suggestions would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Running total from mixed codes in Columns.

    Hello trownson,

    Welcome to the Forum!

    Do you want to a button that will print the "ledger" for the selected company or would you like to create the "ledger" and have the option of printing?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-27-2010
    Location
    New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Running total from mixed codes in Columns.

    Hi Leith, Thanks.
    Its not the printing aspect that we want to achieve.

    It's more about a total of the each accumulative CODE as we work down the sheet based on the date or CODE.

    i.e at any date we want to see the total of CODE 310 or 463

    Thanks.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Running total from mixed codes in Columns.

    Hello trownson,

    So, you want running totals for each code. Do you still the ledger format for this?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    07-27-2010
    Location
    New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Running total from mixed codes in Columns.

    Hi Leith
    Yes, to running totals. RE: Ledger format; - If we can keep in the ledger format, Great! If not, no problem.
    Thanks.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Running total from mixed codes in Columns.

    Hello trownson,

    I'll see what I can come up with and then have you look it over. We can make any needed changes afterward.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  7. #7
    Registered User
    Join Date
    07-27-2010
    Location
    New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Running total from mixed codes in Columns.

    Thanks very much Leith.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Running total from mixed codes in Columns.

    Hello trownson,

    Do you have any other odd codes like "501/50" ? Would this follow code 400?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Running total from mixed codes in Columns.

    Hello trownson,

    Here is the first draft of the ledger macro. The formatting stills needs a little work. Have a look a let me know if this close to what you wanted. I am including the macro code here for those who may be interested. This has already been added to the attached workbook.
    Sub CreateLedger()
    
      Dim Cell As Range
      Dim Codes As Object
      Dim Key As Variant
      Dim R As Long
      Dim RowNum As Variant
      Dim Rng As Range
      Dim StartRow As Long
        
        With Worksheets("Template")
          Set Rng = .Range("E5:E25")
          Set Codes = CreateObject("Scripting.Dictionary")
          Codes.CompareMode = vbTextCompare
          
           'Save each code along with the rows where it is found
            For Each Cell In Rng
              Key = Trim(Cell)
              If Key <> "" Then
                If Not Codes.Exists(Key) Then
                   Codes.Add Key, Cell.Row
                Else
                   Codes(Key) = Codes(Key) & "," & Cell.Row
                End If
              End If
            Next Cell
          
         'Check that there are codes
          If Codes.Count = 0 Then Exit Sub
           
         'Use column "AA" as a helper column to sort the codes
          Set Rng = .Range("AA1:AA" & Codes.Count)
          Rng.Value = WorksheetFunction.Transpose(Codes.Keys)
          
         'Sort the codes in ascending order
          Rng.Sort Key1:=Rng.Cells(1, 1), Order1:=xlAscending, Header:=xlNo, _
                   MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
          
        End With
        
        With Worksheets("Ledger")
          R = 1                            'Starting row on Ledger sheet
          .Cells.Clear
          
           'List the Codes and their entries
            For Each Key In Rng
             'Display the code number
              .Cells(R, "A").Font.Bold = True
              .Cells(R, "A").HorizontalAlignment = xlHAlignLeft
              .Cells(R, "A").Value = Key
              
             'All codes were saved as text. The worksheet range contains the original values.
              Key = CStr(Key)
              
              R = R + 2                    'Skip a line
              
              StartRow = R                 'Marks the first line entry of this code
              
               'Add the code entries
                For Each RowNum In Split(Codes(Key), ",")
                  .Cells(R, "A").Resize(1, 7).Value = Worksheets("Template").Cells(RowNum, "A").Resize(1, 7).Value
                  R = R + 1
                Next RowNum
                
              R = R + 1                    'Skip a line
              
             'Add the Total Line and Sum formula
              With .Cells(R, "A").Resize(1, 7).Borders(xlEdgeBottom)
                .LineStyle = xlContinuous
                .Weight = xlThin
              End With
              .Cells(R, "A").Font.Bold = True
              .Cells(R, "A").Value = "TOTAL"
              .Cells(R, "G").Font.Bold = True
              
              .Cells(R, "G").Formula = "=Sum(G" & StartRow & ":G" & R - 2 & ")"
              
              R = R + 3                    'Skip 2 lines between codes
            Next Key
            
        End With
        
    End Sub
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0