+ Reply to Thread
Results 1 to 2 of 2

Apply Filter & Delete Visible Rows To Extract Data for only One Account # in Data Set

Hybrid View

  1. #1
    Registered User
    Join Date
    11-12-2015
    Location
    Washington DC
    MS-Off Ver
    2013
    Posts
    34

    Apply Filter & Delete Visible Rows To Extract Data for only One Account # in Data Set

    Hi All,

    I download a file frequently that has data for multiple accounts. I'm trying to write a proc that will separate the data by account number and put the data for each account in its own worksheet. My approach was to copy active sheet to a new sheet apply a filter excluding all but one account and selecting and deleting all visible cells and then going back to the main worksheet and repeating for each account. What I have so far is not working. I'm getting errors on the "Rows("1:1").Delete Shift:=xlUp" line. When I comment that line out then I get an error on the next line. any help would be appreciated. Also If someone can tell me how to save each worksheet into a separate workbook that would be cool too.

    Sub SeperateAccounts()
    
        ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
        
       'First row is deleted because the source data has an unwanted first row.
       Rows("1:1").Delete Shift:=xlUp
        
        ActiveSheet.Range("A:Q").AutoFilter Field:=9, Criteria1:=Array( _
            "111520", "111535", "111540", "111599", "112004", "112710", "113401"), Operator:= _
            xlFilterValues
        
        Selection.SpecialCells(xlCellTypeVisible).Select
        Selection.Delete Shift:=xlUp
        
        'This is done because the operation above deletes the headding
        Rows("1:1").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        
     [A1] = "JV Unit"
     [B1] = "Journal ID"
     [C1] = "Date"
     [D1] = "Year"
     [E1] = "Period"
     [F1] = "Source"
     [G1] = "Line Unit"
     [H1] = "Oper Unit"
     [I1] = "Account"
     [J1] = "AcctGrp"
     [K1] = "Amount"
     [L1] = "Line Descr"
     [M1] = "Voucher"
     [N1] = "Invoice"
     [O1] = "Vendor"
     [P1] = "Name"
     [Q1] = "AP Descr"
        
    End Sub

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Apply Filter & Delete Visible Rows To Extract Data for only One Account # in Data Set

    Wouldn't it be easier to filter for the account you want and then copy the visible rows?

    Here's a hint
    ActiveSheet.AutoFilter.Range.Copy
    Workbooks.Add.Worksheets(1).Paste
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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. [SOLVED] apply formula to only those rows that are visible after sort
    By mlski4751 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-08-2016, 03:54 AM
  2. Filter/delete rows based on data from different sheet?
    By realrookie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-20-2016, 03:53 PM
  3. VBA, Delete blank rows with no visible data in Column A
    By TylerLuk1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-20-2015, 10:06 AM
  4. delete all visible rows after a filter
    By penfold1992 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-10-2013, 07:02 AM
  5. Filter/Delete.Rows then Copy New Data and Insert xldown
    By exc4libur in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-14-2011, 06:36 PM
  6. Delete adjacent (hidden) data when deleting visible data
    By delirium in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 12-21-2009, 12:02 PM

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