Results 1 to 7 of 7

Autosum

Threaded View

JohnathanC Autosum 03-09-2010, 02:41 PM
royUK Re: Autosum 03-09-2010, 03:30 PM
royUK Re: Autosum 03-09-2010, 03:36 PM
JohnathanC Re: Autosum 03-09-2010, 04:04 PM
royUK Re: Autosum 03-09-2010, 06:20 PM
JohnathanC Re: Autosum 03-10-2010, 04:32 PM
JohnathanC Re: Autosum 03-10-2010, 04:37 PM
  1. #1
    Registered User
    Join Date
    03-09-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    35

    Question Autosum

    Okay guys, I'm stymied on this one. I've been working on creating an auto-reporting tool and I'm stuck.

    I have been working in a "scratchbook" (book4.xlsm) to ensure that I have proper coding before importing it into my final product.

    My line of code says to run the data table through a series of filters, autosum the results and then paste them into a cell on the summary page. Then, it resets the filters and runs the data through the process again, changing the filters and the output cell destination.

    In Book4.xlsm the macro works EXACTLY like it is supposed to. So, I copied the macro coding and pasted into the "reporting tool.xlsm". I included the lines to activate the "Monthly report.xls" and the correct sheet and select a cell in the data range. I even left the auto-refresh update ON so that I could see what's happening.

    Now, the coding does NOT work properly. it's EXACTLy the same code from book4, but it doesnt work. It's supposed to only be auto-summing the VISIBLE cells. But now, it's returning a random number. At first I thought that it was returning the results for ALL of column N, visible and hidden, but even that isnt the case. The results for Column N when auto-summed manually are "74918.28", however the macro is returning a result of "230144.65" and I cannot ascertain where that figure is coming from. Additionally, it's returing this same value for every single filter.

    I'm stuck. Please, please help!

    The code is below:

    ******************************************
    Sub Calculate()
    
    Call RVRTotals
    
    
    End Sub
    
    Sub RVRTotals()
    
    Windows("Monthly Finance Report.xls").Activate
    Sheets("RVR Detail").Select
    Range("A3").Select
    
    Call RVR_GMH_NonXIX
    Call RVR_GMH_XIX
    Call RVR_GMH_XXI
    
    Call RVR_SMI_NonXIX_Cenpatico
    Call RVR_SMI_XIX_Cenpatico
    Call RVR_SMI_XXI_Cenpatico
    
    Call RVR_SMI_NonXIX_Apache
    Call RVR_SMI_XIX_Apache
    Call RVR_SMI_XXI_Apache
    
    Call RVR_SMI_NonXIX_NARBHAFFS
    Call RVR_SMI_XIX_NARBHAFFS
    Call RVR_SMI_XXI_NARBHAFFS
    
    Sheets("Summary").Select
    
    
    End Sub
    
    Sub RVR_GMH_NonXIX()
    
    ' Subtotals RVR GMH Non-XIX values
    Range("a3").Select
    
        Selection.AutoFilter
        Selection.AutoFilter Field:=7, Criteria1:="GMH"
        Selection.AutoFilter Field:=6, Criteria1:="Non XIX"
    
    Dim b As Range
     
    ' create range in column N from row 2 to the last visible cell with data
    With Sheet1
        Set b = .Range("N2", .Range("N" & .Rows.Count).End(xlUp))
    End With
     
    Range("S1").Value = WorksheetFunction.Sum(b.SpecialCells(xlCellTypeVisible))
    
    Range("S1").Select
    Selection.Copy
    
    Worksheets("Summary").Activate
    Range("E10").PasteSpecial
    Worksheets("RVR Detail").Activate
    Selection.AutoFilter
    
    End Sub
    
    Sub RVR_GMH_XIX()
    
    ' Subtotals RVR GMH Non-XIX values
    Range("A3").Select
    
    
        Selection.AutoFilter Field:=7, Criteria1:="GMH"
        Selection.AutoFilter Field:=6, Criteria1:="XIX"
    
    Dim a As Range
     
    ' create range in column N from row 2 to the last visible cell with data
    With Sheet1
        Set a = .Range("N2", .Range("N" & .Rows.Count).End(xlUp))
    End With
     
    Range("S1").Value = WorksheetFunction.Sum(a.SpecialCells(xlCellTypeVisible))
    
    Range("S1").Select
    Selection.Copy
    
    Worksheets("Summary").Activate
    Range("F10").PasteSpecial
    Worksheets("RVR Detail").Activate
    Selection.AutoFilter
    
    End Sub
    Sub RVR_GMH_XXI()
    
    ' Subtotals RVR GMH Non-XIX values
    Range("a3").Select
    
        Selection.AutoFilter Field:=7, Criteria1:="GMH"
        Selection.AutoFilter Field:=6, Criteria1:="XXI"
    
    Dim a As Range
     
    ' create range in column N from row 2 to the last visible cell with data
    With Sheet1
        Set a = .Range("N2", .Range("N" & .Rows.Count).End(xlUp))
    End With
     
    Range("S1").Value = WorksheetFunction.Sum(a.SpecialCells(xlCellTypeVisible))
    
    Range("S1").Select
    Selection.Copy
    
    Worksheets("Summary").Activate
    Range("G10").PasteSpecial
    Worksheets("RVR Detail").Activate
    Selection.AutoFilter
    
    End Sub
    
    
    
    
    
    Sub RVR_SMI_NonXIX_Cenpatico()
    
    ' Subtotals RVR GMH Non-XIX values
    Range("a3").Select
    
        Selection.AutoFilter Field:=7, Criteria1:="SMI"
        Selection.AutoFilter Field:=6, Criteria1:="Non XIX"
        Selection.AutoFilter Field:=1, Criteria1:="Cenpatico"
        
    
    Dim a As Range
     
    ' create range in column N from row 2 to the last visible cell with data
    With Sheet1
        Set a = .Range("N2", .Range("N" & .Rows.Count).End(xlUp))
    End With
     
    Range("S1").Value = WorksheetFunction.Sum(a.SpecialCells(xlCellTypeVisible))
    
    Range("S1").Select
    Selection.Copy
    
    Worksheets("Summary").Activate
    Range("E11").PasteSpecial
    Worksheets("RVR Detail").Activate
    Selection.AutoFilter
    
    End Sub
    Sub RVR_SMI_XIX_Cenpatico()
    
    ' Subtotals RVR GMH Non-XIX values
    Range("a3").Select
    
        Selection.AutoFilter Field:=7, Criteria1:="SMI"
        Selection.AutoFilter Field:=6, Criteria1:="XIX"
        Selection.AutoFilter Field:=1, Criteria1:="Cenpatico"
        
    
    Dim a As Range
     
    ' create range in column N from row 2 to the last visible cell with data
    With Sheet1
        Set a = .Range("N2", .Range("N" & .Rows.Count).End(xlUp))
    End With
     
    Range("S1").Value = WorksheetFunction.Sum(a.SpecialCells(xlCellTypeVisible))
    
    Range("S1").Select
    Selection.Copy
    
    Worksheets("Summary").Activate
    Range("F11").PasteSpecial
    Worksheets("RVR Detail").Activate
    Selection.AutoFilter
    
    End Sub
    Sub RVR_SMI_XXI_Cenpatico()
    
    ' Subtotals RVR GMH Non-XIX values
    Range("a3").Select
    
        Selection.AutoFilter Field:=7, Criteria1:="SMI"
        Selection.AutoFilter Field:=6, Criteria1:="XXI"
        Selection.AutoFilter Field:=1, Criteria1:="Cenpatico"
        
    
    Dim a As Range
     
    ' create range in column N from row 2 to the last visible cell with data
    With Sheet1
        Set a = .Range("N2", .Range("N" & .Rows.Count).End(xlUp))
    End With
     
    Range("S1").Value = WorksheetFunction.Sum(a.SpecialCells(xlCellTypeVisible))
    
    Range("S1").Select
    Selection.Copy
    
    Worksheets("Summary").Activate
    Range("G11").PasteSpecial
    Worksheets("RVR Detail").Activate
    Selection.AutoFilter
    
    End Sub
    
    Sub RVR_SMI_NonXIX_Apache()
    
    ' Subtotals RVR GMH Non-XIX values
    Range("a3").Select
    
        Selection.AutoFilter Field:=7, Criteria1:="SMI"
        Selection.AutoFilter Field:=6, Criteria1:="Non XIX"
        Selection.AutoFilter Field:=1, Criteria1:="Apache TRBHA"
        
    
    Dim a As Range
     
    ' create range in column N from row 2 to the last visible cell with data
    With Sheet1
        Set a = .Range("N2", .Range("N" & .Rows.Count).End(xlUp))
    End With
     
    Range("S1").Value = WorksheetFunction.Sum(a.SpecialCells(xlCellTypeVisible))
    
    Range("S1").Select
    Selection.Copy
    
    Worksheets("Summary").Activate
    Range("E12").PasteSpecial
    Worksheets("RVR Detail").Activate
    Selection.AutoFilter
    
    End Sub
    Sub RVR_SMI_XIX_Apache()
    
    ' Subtotals RVR GMH Non-XIX values
    Range("a3").Select
    
        Selection.AutoFilter Field:=7, Criteria1:="SMI"
        Selection.AutoFilter Field:=6, Criteria1:="XIX"
        Selection.AutoFilter Field:=1, Criteria1:="Apache TRBHA"
        
    
    Dim a As Range
     
    ' create range in column N from row 2 to the last visible cell with data
    With Sheet1
        Set a = .Range("N2", .Range("N" & .Rows.Count).End(xlUp))
    End With
     
    Range("S1").Value = WorksheetFunction.Sum(a.SpecialCells(xlCellTypeVisible))
    
    Range("S1").Select
    Selection.Copy
    
    Worksheets("Summary").Activate
    Range("F12").PasteSpecial
    Worksheets("RVR Detail").Activate
    Selection.AutoFilter
    
    End Sub
    (Truncated due to length)....all the rest is the same as above...
    Last edited by JohnathanC; 03-10-2010 at 04:37 PM.

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