Problems with dates and today()

markdenovan

Board Regular
Joined
Dec 15, 2002
Messages
97
I've got a cell and a column of cells formatted as dd/mm/yyyy

I've got an autofilter on the column of cells and use the single cell for the criteria.

So I have:

example 04/01/2004 dd/mm/yyyy

single cells formula =today()-1

Macro autofilter code:

Selection.AutoFilter Field:=1, Criteria1:=Range("menu!e8").Value

This works fine on my machine, but on another machine the autofilter doesn't find any matches. If I have a look at the filter, it is looking for 1/04/2004.

Its obviously a problem with date formatting.

Can anyone help me?

Is there a way to format the today() function ie today(dd/mm/yyyy)?

Many thanks,

Mark
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi,

I don't think it is a formatting issue as formatting should not matter.

Check if:

- your cells have text instead of date

- it is a language version issue ( change to another date format and see if it is the correct date that is displayed)
 
Upvote 0
Hi Mark,

Try amending the filter code to something along these lines:
Code:
Sub Filter()

    With Worksheets("Sheet1")
        .Range("C1").AutoFilter _
            Field:=1, Criteria1:="<=" & Format(.Range("A1"), "mm/dd/yyyy")
    End With

End Sub
HTH
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,174
Members
449,071
Latest member
cdnMech

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