+ Reply to Thread
Results 1 to 1 of 1

coding to add a subtotal when filtering then copying rows to another sheet

  1. #1
    Registered User
    Join Date
    06-24-2013
    Location
    Reading CA
    MS-Off Ver
    Excel 2010
    Posts
    10

    coding to add a subtotal when filtering then copying rows to another sheet

    I have a spreadsheet in which I use a macro to create reports by a unique project number. This is done by generating a master file for all projects. This list creates a subtotal as the last row of the report. It automatically updates when you filter by project.

    However when I run the reports for all projects, it does not include the subtotal line. Is their a routine that can be run to advise it to always include that line?

    Here is the coding I have. Ideally in this section, I want to copy the project number to the line below what it finds so that it includes the subtotal prior to pasting to another sheet. Currently there are 96000 lines and each project number of lines vary. The subtotals currently always the last row, however we filter on the project number. No other filterable field is a viable option. When the project filters it copies only the visible lines to a new spreadsheet. It does this for each project and saves it as a unique xlsx file.

    I need the file to add the subtotals that is automatically hidden when the file filters. It could simply copy the project number to last row (overwrite each time a new project is run) and refilter. But I cannot get that to work. Please advise. I have included the portion of the coding below that I have working

    'Filter and copy it to the ProjectSegments sheet
    With ThisWorkbook
    .Sheets("QueryResults").Range("$A:$AY").AutoFilter Field:=1, Criteria1:=Numb

    If Choice <> "Robert" Then
    .Sheets("QueryResults").Range("$A:$AY").AutoFilter Field:=2, Criteria1:="<>BL"
    End If

    .Sheets("QueryResults").UsedRange.SpecialCells(xlCellTypeVisible).Copy
    .Sheets("ProjectSegments").Range("A1").PasteSpecial xlPasteAll
    Last edited by rjackson104; 01-21-2019 at 08:46 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 02-04-2014, 08:43 AM
  2. Need help coding vba in Excel: copying from one sheet to another
    By SimpleGirl in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-26-2013, 08:52 AM
  3. Hidden Rows being Overridden wihen Filtering & Copying
    By Pomrloo in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-11-2013, 04:06 PM
  4. [SOLVED] Issue with Copying data to a New Sheet After Filtering.
    By AparnaSriram in forum Excel General
    Replies: 10
    Last Post: 11-16-2012, 04:17 AM
  5. Subtotal - Delete zero Subtotal and prior rows that calculate to that zero Subtotal
    By Whatsherface in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2012, 08:37 PM
  6. Filtering Results and Copying Each Result to a Seperate Sheet
    By gjaylward2008 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-16-2012, 04:10 PM
  7. Copying rows which satisfies a filtering condition
    By blurtoad in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-06-2007, 11:31 AM
  8. HELP-- Filtering and copying data to a new sheet (w/ macro)
    By Voldemore in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-17-2005, 05:05 PM

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.6.0 RC 1