Filter will not compile!

KasperC

New Member
Joined
May 11, 2023
Messages
49
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello,

Because of the success after my first post, I've decided to come back as I'm quite stuck again..

I'm trying to filter a range of dates for a ceirtan date that is given in cell L1 in the "ws" worksheet, but I can't seem to be able to filter for this value.
(for the record, my date-format is DDMMYYYY. The value in cell L1 has this format: DD.MM.YYYY)

Upon running the sub, a compiling error appears stating that "named argument not found".

VBA Code:
Private Sub MySub()
    Dim ws As Worksheet
    Dim wb As Workbook
    Dim adato As String
    
    Set wb = ThisWorkbook
    Set ws = wb.Worksheets("Inn")
    
    adato = Range("L1").Value
    
    ws.Range("C1").AutoFilter Field:=3, Cirteria1:="=01062023" ' <- I want Criteria1 to be "adato", but just for displaying purposes I've changed it to the date/value I want to filter for, in this case "01.06.2023".

End Sub

Does anyone have any idea how to fix this issiue?

Thank you for your time.

Regards,
Kasper C
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
You misspelled "Criteria":
Rich (BB code):
ws.Range("C1").AutoFilter Field:=3, Cirteria1:="=01062023"
Note: Format has no affect on the criteria. Excel runs on the actual value, not the formatted displayed value.
So you may need to use a valid date entry instead of what you show now (which is not a valid date entry).
 
Upvote 1
Solution
Edit:
ws.Range("C1").AutoFilter Field:=3, Cirteria1:="=01.06.2023"

Also, how can I edit my post?
 
Upvote 0
Edit:
ws.Range("C1").AutoFilter Field:=3, Cirteria1:="=01.06.2023"
See my reply.
Also, how can I edit my post?
You cannot edit your own posts until you reach a certain number of posts (I do not remember if it is 10 or 50, off the top of my head).
After that, you have 10 minutes in which to edit it.
 
Upvote 0
See my reply.

You cannot edit your own posts until you reach a certain number of posts (I do not remember if it is 10 or 50, off the top of my head).
After that, you have 10 minutes in which to edit it.

I feel like such an idiot - been looking at this for the past hour..

Also, noted - should probably look closer at the community rules 😅

Thank you so much!
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 1

Forum statistics

Threads
1,215,004
Messages
6,122,656
Members
449,091
Latest member
peppernaut

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