Filtering data by City and Date

  • Here is my problem:


    I have a mastersheet with thousands of data and multiple Headers, and I only need the number of data that meets my criteria in a specific month. My idea was to filter first by the city, because i dont care about the others, but since its a huge sheet and they have data since 2013, and Im only interested in for exemple October,2017. im trying to filter again using the month I need but i just cant do it.


    The Date Column is typed by hand and it is in the format dd/mm/yyyy



    With this code i can filter by city name, but when i try to do by date it wont work.


    If i type the whole date for exemple :


    .AutoFilter Field:=19, Criteria1:= 02/10/2017


    it shows results, but I dont want it to show only a specific day I want a entire month. So I tried changing the line for this:


    .AutoFilter Field:=19, Criteria1:= ??/10/2017 and .AutoFilter Field:=19, Criteria1:= **/10/2017


    I also tried changing the date format to mm/dd/yyyy and none of them gave any results, even though they exist


    I Looked everywhere and couldnt find a answer to this and thats why im here.


    I cant share the data workbook so I tried to be clear as possible but i not sure if it is. Anyway thanks for the help


    This filtering processes is only the begging of what im trying to do. If I can pass this step im trying to make so that the Month it will search it will be based by the name of the worksheet. For Exemple if the sheet is named Oct 17 it will filter by the Month October in the year 2017.


    This part im not sure if its possible thats why I didnt put in the main question but if you guys have any ideia if its possible ill be thankful if any information is given of how do it

  • Hello,


    You could test the following instruction :


    Code
    Range("A1:V1").AutoFilter Field:=19, Criteria1:=">=" & "02/10/2017", Operator:=xlAnd, Criteria2:="<=" & "31/10/2017"


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • it worked thanks


    Glad you could fix your problem ... :wink:


    Thanks ... for your Thanks ...AND for the Like ... :smile:

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!