+ Reply to Thread
Results 1 to 7 of 7

Autosum

Hybrid View

  1. #1
    Registered User
    Join Date
    03-09-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Autosum

    ? .... I didnt edit anything?

  2. #2
    Registered User
    Join Date
    03-09-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Autosum

    OKay then, as per "Rule 9", here was my solution.

    I had one workbook RUNNING the macro, and pasting the information into an "output" file. Here's what I wrote.

    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
    What ended up happening with that was that the file executing the code was autosumming the data in the range in that workbook instead of the range of the output file.

    The problem was here:

    With Sheet1
        Set b = .Range("N2", .Range("N" & .Rows.Count).End(xlUp))
    End With
    Since I had "activated" the output file earlier in the code I changed the code to this:

    With ActiveSheet
        Set b = .Range("N2", .Range("N" & .Rows.Count).End(xlUp))
    End With
    and Bob's your uncle.

+ 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