+ Reply to Thread
Results 1 to 21 of 21

Filter Specific Column of Selected files to Master File

  1. #1
    Forum Contributor
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    105

    Post Filter Specific Column of Selected files to Master File

    Hi,

    I am using the below VBA Code to filter some specific column (Source file- Active Workbook) and paste in new work book

    I need to do this activity for many files. can someone help to modify the code as below.

    I need to select multiple files instead of active workbook, then one be one all files to be copied and pasted in new work book.

    Example if i select 5 excel files, (All in same folder only) first excel file to be copied and pasted in new workbook (as per sample vba code) and then the new workbook to be saved as main file.
    then the second excel file (out of 5) to be copied and pasted in last row of main file.

    Currently i am opening one by one and running the macro. Macro is working fine, however instead opening one by one and running the code, i am seeking some one help to modify the code instead of active workbook to selection of excel files.

    Kindly help to modify the above code.

    Sub Dates()

    Dim wb As Workbook: Set wb = ActiveWorkbook
    Dim a: a = ActiveSheet.Range(Cells(6, 1), Cells(6, ActiveSheet.UsedRange.Columns.Count))
    With ActiveSheet.Range("C1:C" & ActiveSheet.UsedRange.Rows.Count)
    .Value = Evaluate(Replace("if(isnumber(@),@)", "@", .Address))
    .Parent.UsedRange.AutoFilter 3, "<>False"
    .Parent.UsedRange.SpecialCells(12).Copy
    End With

    Workbooks.Add
    [A1].PasteSpecial xlPasteAll
    [A1].Resize(, UBound(a, 2)) = a

    Application.DisplayAlerts = False
    wb.Close False
    Application.DisplayAlerts = True

    End Sub

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Filter Specific Column of Selected files to Master File

    Possibly...
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    105

    Re: Filter Specific Column of Selected files to Master File

    The code is selecting excel files, but can you help me how to link your code with above my code.

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Filter Specific Column of Selected files to Master File

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    105

    Re: Filter Specific Column of Selected files to Master File

    Hi dangelor.

    Thanks for your code. while running the code its opening the selected excel files. but copy and pasting in new sheet not happening.

    "Workbooks.Add" kindly make this file as master file and then one by one pasted in this workbook.

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Filter Specific Column of Selected files to Master File

    In this bit of code:
    Please Login or Register  to view this content.
    you are creating a new workbook for every file, and you are pasting something into Range ("A1"), and then immediately overwriting it with the contents of the variable a.
    What is it you are trying to accomplish? (Sample workbooks would be helpful to finding a solution)

  7. #7
    Forum Contributor
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    105

    Re: Filter Specific Column of Selected files to Master File

    Hi let me explain in detail for the the existing code
    The existing code is not for multiple files from one Excel CSV workbook header starting from row 6, on row 6 column C filtering only dates rows (excluding other than date rows)then copying filtered data to new workbook starting from row A1

    Currently I am trying to change the above code as below

    The existing code I am doing for one csv file, in new code I need to select multiple csv files, each files to be copied (filtering columnC6 with only dates as per existing code) then to be pasted in one workbook. Means output should be single file, each file one by one copied and pasted in one workbook. We can give fixed name for this workbook as master file

  8. #8
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Filter Specific Column of Selected files to Master File

    Try this version...
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    105

    Re: Filter Specific Column of Selected files to Master File

    Hi dangelor

    Thank you so much. code is working as expected. only one issue is that, its copying other row if its having value. though column C is blank.

  10. #10
    Forum Contributor
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    105

    Re: Filter Specific Column of Selected files to Master File

    Hi Dangelor.

    I have attached sample excel file for your reference. Refer Cell AH24 & A2 ,though column C is blank its coming in Output
    C2 also coming in output though its not a "date row". Kindly help to fix this .
    Attached Files Attached Files

  11. #11
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Filter Specific Column of Selected files to Master File

    Place this code in a standard module in the Master workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    105

    Re: Filter Specific Column of Selected files to Master File

    Hi Refer the output file (Master Latest) Row AH23
    Though no data on Column C its its appearing in output file.
    Kindly help to fix this.

    And instead of "standard module in the Master workbook" is it possible to run the code from "Personal Macro workbook" (Earlier Code Worked)
    Attached Files Attached Files

  13. #13
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Filter Specific Column of Selected files to Master File

    Try this version...
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    105

    Re: Filter Specific Column of Selected files to Master File

    Thanks for your code. Still other rows data is appearing in out put file, though no date in column "C".
    Attached Sample file Refer AG 36 and AH36

    out put File Refer AG23 and AH23 marked in yellow colour. Kindly help.
    Attached Files Attached Files

  15. #15
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Filter Specific Column of Selected files to Master File

    The latest csv file has rows that were not in the previous versions. Will your working csv files also have the added rows? If so, the autofilter section of the code will need to be revamped.

  16. #16
    Forum Contributor
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    105

    Re: Filter Specific Column of Selected files to Master File

    Yes I shared sample file however working file having added rows. It's having data in other columns excluding column C. Please help to revamp the code.

  17. #17
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Filter Specific Column of Selected files to Master File

    I'll try to get something before the end of today

  18. #18
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Filter Specific Column of Selected files to Master File

    One last try...
    Please Login or Register  to view this content.

  19. #19
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Filter Specific Column of Selected files to Master File

    @dangelor … I have encountered similar issue when I provided the first part of the code for a previous thread request. The issue is the OP CSV files don't have consistency in all columns. i.e. You're checking last row based on column C whereas if you refer back to the original code I have lookup the last row based on the used range of the sheet to ensure while filtering I capture all rows with data

    @SARAN89, try to change the below line based on @dangelor code in post # 18 & see if that solves your issue

    Please Login or Register  to view this content.
    Last edited by nankw83; 05-11-2020 at 02:35 PM.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  20. #20
    Forum Contributor
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    105

    Re: Filter Specific Column of Selected files to Master File

    Hi dangelor Code is working fine after replacing "lRow = ws.Cells(1, 3).End(xlDown).Row " with lRow = ws.UsedRange.Rows.Count suggested by Nankw83. Thank you so much for your help.

  21. #21
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Filter Specific Column of Selected files to Master File

    Glad I was able to somewhat help.

+ 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] Cycling through files and copying specific/variable ranges to master file
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-04-2017, 06:31 AM
  2. Copy specific rows from many files and paste into next empty row in master file
    By Rednalyn in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-08-2013, 09:13 AM
  3. Using a macro to pull specific data from multiple files into a master file
    By bocaj315 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2013, 09:31 AM
  4. Extract Same Column From Different Excel files into One Master File [Help]
    By cosi in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-30-2013, 09:46 AM
  5. [SOLVED] Want to merge specific cells from 1000+ files into one master file
    By dunnybocter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-15-2013, 02:52 AM
  6. Copy specific cells from many files into master file
    By cmgst49 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2012, 03:05 PM
  7. Replies: 8
    Last Post: 06-27-2012, 03:09 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