Results 1 to 1 of 1

Subtotal won't function properly using VBA

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-01-2006
    Location
    Erie, Pa USA
    MS-Off Ver
    Vista - Excel 2003
    Posts
    132

    Subtotal won't function properly using VBA

    Hi,
    I use shift-end-down, then shift-end-right to select all data in my spreadsheet.

    I then click Data, Subtotals, and select At each change in column = B, Use Function = Sum, Add Subtotal to = Column R and click ok.
    Then I do the same for column D.

    Works fine - I get subtotals for both column D and Column B for all the rows in the spreadsheet.

    I record this in VBA and this is the code:
    Range(Selection, Selection.End(xlDown)).Select
        Range(Selection, Selection.End(xlToRight)).Select
        Selection.Subtotal GroupBy:=2, Function:=xlCount, TotalList:=Array(18), _
            Replace:=True, PageBreaks:=False, SummaryBelowData:=True
        Selection.Subtotal GroupBy:=4, Function:=xlCount, TotalList:=Array(18), _
            Replace:=False, PageBreaks:=False, SummaryBelowData:=True
    When the recorded macro is run, the last row is not included in the column D subtotal count. It is left by itself without a subtotal.

    I have done this over and over and over and get the same result.
    Can anyone see why subtotals functions properly when "live" on the worksheet, but leaves one line out when used in a macro?
    Last edited by HBF; 03-27-2009 at 09:40 AM.

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