+ Reply to Thread
Results 1 to 20 of 20

Excel VBA Autofilter date between two cells in each rows

  1. #1
    Registered User
    Join Date
    01-11-2017
    Location
    India
    MS-Off Ver
    2021
    Posts
    14

    Excel VBA Autofilter date between two cells in each rows

    Can someone help me to fix this?

    Currently, I am using the below code and it is working fine. I have dates in Columns "G" and "J". Now I need to add one more filter on the column "G" (Field:=7). If the date in column "G" is greater than the date in Column "J" (or) the column "J" is Blank cell, Then it needs to be filtered. It would be greatly appreciated. Thank you.

    Also, I have attached the Excel file. In case you want to check this. Thank you.

    Book1.xlsm

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,265

    Re: Excel VBA Autofilter date between two cells in each rows

    Add a column with your additional logic to return TRUE/FALSE and then use that column in your autofilter, showing either TRUE or FALSE depending on your desired display.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    01-11-2017
    Location
    India
    MS-Off Ver
    2021
    Posts
    14

    Re: Excel VBA Autofilter date between two cells in each rows

    Hi Bernie Deitrick,

    Understood. I can do that if it is a new file. But I have around 500 existing files that I can't add a column in it. it is very difficult for now.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,265

    Re: Excel VBA Autofilter date between two cells in each rows

    Use a macro to add the additional column - you can process 500 files with the click of a button, if you write the code well

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Excel VBA Autofilter date between two cells in each rows

    See if this works as you explaind.
    Please Login or Register  to view this content.

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

    Cool Try this !


    According to the attachment an Excel basics VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
            
    Sheet1.UsedRange.Offset(1).Clear
       With Sheet3
           
    .[M9].Formula "=((D9=""APP"")+(D9=""R&R""))*(F9<>""Completely released"")*(I9<>""AE markups in hand"")*(G9>J9)"
           
    .[B8:J201].AdvancedFilter 2, .[M8:M9], Sheet1.[A1:E1]
       
    End With
            Sheet1
    .UsedRange.Borders.Weight 2
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  7. #7
    Registered User
    Join Date
    01-11-2017
    Location
    India
    MS-Off Ver
    2021
    Posts
    14

    Re: Excel VBA Autofilter date between two cells in each rows

    Hi Jindon, Yes, It is working very fine. Thank you so much for your help

    I have one more question, In the output data, I am getting the following text "01/00/00" in column "D" (refer to below image). Is it possible to replace/remove this text?

    Attachment 846266

  8. #8
    Registered User
    Join Date
    01-11-2017
    Location
    India
    MS-Off Ver
    2021
    Posts
    14

    Re: Try this !

    Hi Marc L, Thanks for your response. But I am getting a runtime error 1004 (Attachment 846267). However the code given by Jindon is working very fine. Thank you.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Excel VBA Autofilter date between two cells in each rows

    Attachment 846266 in post #7 is invalid.

    try this
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    01-11-2017
    Location
    India
    MS-Off Ver
    2021
    Posts
    14

    Re: Excel VBA Autofilter date between two cells in each rows

    Hi Jindon, It is working very fine. Thank you so much for your help.

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Excel VBA Autofilter date between two cells in each rows

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  12. #12
    Registered User
    Join Date
    01-11-2017
    Location
    India
    MS-Off Ver
    2021
    Posts
    14

    Re: Excel VBA Autofilter date between two cells in each rows

    Hi Jindan, I have one more issue when I tried to use this code in all other Excel files, I got the following error "Run-time error '1004' The extract range has missing or invalid field name" in the below location. and the title of the columns has come as "#REF!", Because I had provided the reference formula text in the header text from another worksheet (like ='Weight log'!C7, ='Weight log'!BR7, ='Weight log'!E7) in the excel file. Is it possible to copy the header text (instead of copying formula) into sheet1?


    Please Login or Register  to view this content.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Excel VBA Autofilter date between two cells in each rows

    try change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    01-11-2017
    Location
    India
    MS-Off Ver
    2021
    Posts
    14

    Re: Excel VBA Autofilter date between two cells in each rows

    Yes, It is working very fine. Thank you Jindon.

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

    Arrow Re: Try this !


    Quote Originally Posted by rajeshmuthu View Post
    Hi Marc L, Thanks for your response. But I am getting a runtime error 1004
    No such issue with your initial post attachment …

  16. #16
    Registered User
    Join Date
    01-11-2017
    Location
    India
    MS-Off Ver
    2021
    Posts
    14

    Re: Excel VBA Autofilter date between two cells in each rows

    Hi Jindon, I need a help. Is it possible to get the output of this range of values in a separate variable (instead of copying it into worksheet "Sheet1")? So that I can create a new email and add these output range values to the body of the email. Thank you.

    Please Login or Register  to view this content.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Excel VBA Autofilter date between two cells in each rows

    I just don't understand what you are asking.

  18. #18
    Registered User
    Join Date
    01-11-2017
    Location
    India
    MS-Off Ver
    2021
    Posts
    14

    Re: Excel VBA Autofilter date between two cells in each rows

    Hi Jindon, Sorry I wasn't able to explain clearly. I would like to copy this filtered range table (output data) and paste it into the email body. So that I can send those details (through email) to our manager. Is it possible? Please advise...

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Excel VBA Autofilter date between two cells in each rows

    Possible, but you need to know the basics of HTML with HTMLBody property.

    So better open a new thread for this.

  20. #20
    Registered User
    Join Date
    01-11-2017
    Location
    India
    MS-Off Ver
    2021
    Posts
    14

    Re: Excel VBA Autofilter date between two cells in each rows

    ok Jindon. I will open a new thread. Thank you.

+ 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: 4
    Last Post: 03-16-2013, 08:33 AM
  2. [SOLVED] Need to Autofilter by date and include blank cells
    By Jigsaw314 in forum Excel General
    Replies: 2
    Last Post: 11-05-2012, 08:01 PM
  3. Macro, autofilter, delete rows outside date range, defined names as criteria
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-30-2011, 04:10 AM
  4. After autofilter, Excel is deleting even the hidden rows!
    By JKurz2008 in forum Excel General
    Replies: 4
    Last Post: 11-13-2009, 02:23 AM
  5. [SOLVED] When using Autofilter on Excel, how do I ignore 1st 1 or 2 rows
    By John Driscoll in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-19-2005, 03:15 PM
  6. In Excel my autofilter? is omitting some data rows from output
    By Perplexed Jeff in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2005, 09:05 AM
  7. [SOLVED] Autofilter by Date in Excel 2002
    By Brenda Rueter in forum Excel General
    Replies: 1
    Last Post: 04-25-2005, 02:06 PM
  8. [SOLVED] How to I program on rows after autofilter in Excel?
    By Jacky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2005, 03:08 AM

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