Isolate The Date Portion For NOW

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have this line of code in my project that is giving me a "Unable to get the Match property of the WorksheetFunction class" ...

Code:
dln = WorksheetFunction.Match(td, swb.Worksheets(2).Range("B:B"))

dln is defined as a variant (???)
td = NOW

The value I am getting for td is 5/7/2018 8:03:04 PM
The date data in workbook swb 2nd worksheet is formatted as ddd dd-mm, but is a true date value as indicated in the formula bar (5/7/2018).

I suspect the problem is that they can't match the two values becuase one has the time, the other doesn't so there isn't an exact match. If that is the case, how can I just isolate the date portion of NOW to use to find the match?
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Just use date rather than Now/td

Code:
dln = WorksheetFunction.Match(CLng(Date), swb.Worksheets(2).Range("B:B"))

Date in VBA is the equivalent of the Formula =TODAY() and so doesn't have a time (well strictly speaking a time of 00:00)
 
Last edited:
Upvote 0
Ahhh! Perfect.
Thank you for your help Mark858, it is very appreciated.

I had tried
Code:
dln = WorksheetFunction.Match(int(td), swb.Worksheets(2).Range("B:B"))
...
But that still left me with that error.

Great lesson taught and learned
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,812
Messages
6,127,024
Members
449,352
Latest member
Tileni

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