+ Reply to Thread
Results 1 to 4 of 4

Filter data (Date) and save in new file

  1. #1
    Forum Contributor
    Join Date
    03-08-2021
    Location
    thailand
    MS-Off Ver
    2016
    Posts
    117

    Filter data (Date) and save in new file

    I have file config and input as attached.

    I want to filter column APAPDT in file input by read condition by file config
    Condition : Column APAPDT (format = yyyyddmm)
    value input >= APAPDT1 and value input <= APAPDT2

    I want output after filter save in filename follow filename in column File Name in file config.

    Please guide me about it.

    remark : My real data have input 300K rows
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this …


    According to Logic with such numbers rather than true Excel dates the format must be yyyymmdd …

    Anyway according to your attachment a VBA demonstration as a starting point
    you should amend for what you misexplained or did not ever elaborate :

    PHP Code: 
    Sub Demo1()
        
    Dim VR&
            
    On Error Resume Next
        With Workbooks
    ("input22.xlsx").Worksheets(1).[A1].CurrentRegion
            V 
    Workbooks("Config.xlsx").Worksheets(1).[A1].CurrentRegion.Value2
            
    If Err.Number Then Beep: Exit Sub
            On Error 
    GoTo 0
            Application
    .DisplayAlerts False
            Application
    .ScreenUpdating False
           
    .Range("D1").Copy .Range("Y1:Z1")
            
    Workbooks.Add xlWBATWorksheet
        
    For 2 To UBound(V)
           .
    Range("Y2:Z2").Value2 = Array(">=" V(R1), "<=" V(R2))
           .
    AdvancedFilter 2, .Range("Y1:Z2"), ActiveSheet.[A1]
            
    ActiveWorkbook.SaveAs .Parent.Parent.Path "\" & V(R, 3), 51
            ActiveSheet.UsedRange.Clear
        Next
           .Range("
    Y1:Z2").Clear
        End With
            ActiveWorkbook.Close
            Application.DisplayAlerts = True
            Application.ScreenUpdating = True
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  3. #3
    Forum Contributor
    Join Date
    03-08-2021
    Location
    thailand
    MS-Off Ver
    2016
    Posts
    117

    Re: Filter data (Date) and save in new file

    I can't run your this code.

    It go to Err.Number

    Please guide me about it.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: Filter data (Date) and save in new file


    As no such issue on my side so according to the code did you obviously just forget to open both workbooks ?

+ 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. Save, Date, Rename File and Auto Save
    By COURTTROOPER in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2017, 05:16 AM
  2. Save file using excel Filter
    By matt-43 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2016, 10:30 AM
  3. [SOLVED] Need code to copy data based on filter criteria to new workbook as save in a file location
    By msantucci in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-24-2015, 02:47 AM
  4. [SOLVED] Macro to save file - save name from cell containing a date using different date formatting
    By d_max_c in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-15-2014, 12:18 PM
  5. [SOLVED] save open worksheet to file and include date of save
    By shaz0503 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-12-2014, 08:50 AM
  6. macro required to filter data on several tabs and save to a file, then repeating action
    By Stevengreen22 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-04-2012, 10:26 AM
  7. How to set file Filter in Save dialog box
    By sreenath205 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2006, 08:53 AM

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