Filtering column between 2 values, which source is in data vaulation.

TomeK712

New Member
Joined
Aug 8, 2017
Messages
17
Office Version
  1. 2019
Platform
  1. Windows
Hi All,

I do have an issue with filtering a column between two values, which have a source in a different worksheet as a Data Valuation.

I've got a column with dates and times. I need to filter it up between values which are in format:
Code:
=TEXT(TODAY(), "dd-mm-yyyy")&" 10:00:00"
=TEXT(TODAY(), "dd-mm-yyyy")&" 11:00:00"
=TEXT(TODAY(), "dd-mm-yyyy")&" 12:00:00"
=TEXT(TODAY(), "dd-mm-yyyy")&" 13:00:00"
The date will be changing everyday, time range will be this same.

My VBA code is:
Code:
        If Worksheets("MENU").CheckBoxes("CheckBox1").Value = 1 Then
            Dim lngStart As Range, lngEnd As Range
                Set lngStart = Worksheets("MENU").Range("I17") 'first data valuation
                Set lngEnd = Worksheets("MENU").Range("K17") 'second data valuation
                Worksheets("INBOUND").Range("$A$1:$Y$2000").AutoFilter Field:=11, _
                Criteria1:=">=" & lngStart, _
                Operator:=xlAnd, _
                Criteria2:="<=" & lngEnd
        End If

When the macro is running with Range("I17") and ("K17") as a Data Valuation cell it doesn't work. As soon as I'll disable data valuation and leave the value as 10-08-2017 10:00:00 it works perfectly.

I don't know why my code is not reading the value from Data Valuation, I couldn't find a similar thread to my as well.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
The TEXT function creates the dates as text.
Change the format in date.
 
Upvote 0
The thing is I need to update the date every day, is there option to use a different formula to setup the cell as "dd-mm-yy hh:mm", where the date is 'live' and time is always this same?
 
Upvote 0
=TODAY()+10/24

numbernotation - custom: dd-mm-yyyy hh:mm:ss;@
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,800
Messages
6,126,980
Members
449,351
Latest member
Sylvine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top