Problem With "Match" of Dates

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Rich (BB code):
With ws_staffrec
        sdate = .Range("AF6").Value
        refrow = Application.WorksheetFunction.Match(sdate, ws_master.Columns(1), 0)

The line in red is giving me an "Unable to get the Match property of the WorksheetFunction class." error.

The value of sdate [ws_staffrec.range("AF6")] = 2020-04-09 (sdate is declared date)
A value of 2020-04-09 exists in ws_master, column 1 at cell A116.

Is anyone able to advise why my match is failing? I know working with dates can sometimes be awkward.
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I usually turn the date to an integer and look for that eg CLng(sdate) rather than sdate
 
Upvote 0
See if this works
VBA Code:
With ws_staffrec
    sdate = CDate(.Range("AF6").Value)
    Set refcell = ws_master.Columns(1).Find(sdate)
    If Not refcell Is Nothing 
        Then refrow = refcell.Row
This should also catch any errors if the date is not found
 
Upvote 0
Thank you Steve the Fish, you solution provided the results I was looking for. Jason, thank you as well. I haven't had an opportunity to test your solution, but I anticipate an opportunity further into my code. I like the fact that it would catch any errors resulting for the date not being available.

I appreciate all your help folks.
 
Upvote 0

Forum statistics

Threads
1,214,817
Messages
6,121,717
Members
449,050
Latest member
MiguekHeka

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