+ Reply to Thread
Results 1 to 2 of 2

Daily Totals_Calculate Daily and Monthly Totals_Calculate Monthly Totals

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-15-2005
    Location
    Oklahoma
    MS-Off Ver
    2010, 2013
    Posts
    112

    Daily Totals_Calculate Daily and Monthly Totals_Calculate Monthly Totals

    I routinely use the attached format which has daily totals and create a 2nd worksheet to sum the daily totals to get a monthly total and compare the daily total to monthly total. I then have to create a 3rd worksheet which has only the monthly totals with the ending date of the month. Not all months have 31 days.

    Can anyone help me to write a macro which will do this automatically using the data in the 1st worksheet. This is very tedious work and I know there is an easier solution.

    Thanks,

    Jim15
    Attached Files Attached Files
    Jim15

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,666

    Re: Daily Totals_Calculate Daily and Monthly Totals_Calculate Monthly Totals

    You should be using the SUBTOTAL function on Daily Production sheet.
    Use this macro to calc the subtotals and copy to a new sheet.
    (unable to upload attachment! )

    edit 2/22/12:
    Option Explicit
    
    Sub Macro1()
        Sheets("DAILY PRODUCTION").Select
        Range("E2").Select
        
        Selection.Subtotal _
            GroupBy:=5, _
            Function:=xlSum, _
            TotalList:=Array(2, 3, 4), _
            Replace:=True, _
            PageBreaks:=False, _
            SummaryBelowData:=True
            
        'hide all rows but the subtotals
        ActiveSheet.Outline.ShowLevels rowlevels:=1
        ActiveSheet.Outline.ShowLevels rowlevels:=2
        
        'copy the visible subtotal rows and paste to a new sheet
        ActiveSheet.Cells.SpecialCells(xlCellTypeVisible).Copy
        ActiveSheet.Outline.ShowLevels rowlevels:=3
        
        Sheets.Add After:=Sheets(Sheets.Count)
        ActiveSheet.Name = "Monthly Totals " & Sheets.Count - 1
        ActiveSheet.Paste
        ActiveSheet.Columns(1).EntireColumn.Delete
        ActiveSheet.Range("A1").Select
        
    End Sub
    Attached Files Attached Files
    Last edited by protonLeah; 02-23-2012 at 12:44 AM.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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