Unable to MATCH Dates

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I'm trying to use this code (red line) to determine what row the current date can be found in column B of the worksheet.

Rich (BB code):
        With ws_wstoview
            If .Visible = xlSheetVisible Then
                .Visible = xlSheetHidden
                Worksheets("FRONT").Activate
            Else
                .Visible = xlSheetVisible
                .Activate
                lrow = Application.WorksheetFunction.Match(Date, .Range("B:B"), 0)
                .Cells(lrow, 1).Activate
            End If
        End With

I am receiving an error with the line in red : "Unable to get the Match property of the WorksheetFunction class"

Date, when I hover over it is 3/11/2019.
In worksheet "ws_wstoview", column B, row 41, the value 3/11/2019 exists (as seen in the formula bar ... but formatted in the cell as "Mon 11-Mar")

Why is my code unable to find the answer to the forumla?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi,
try this update to your code & see if helps

Code:
   Dim lrow As Variant
    With ws_wstoview
            If .Visible = xlSheetVisible Then
                .Visible = xlSheetHidden
                Worksheets("FRONT").Activate
            Else
                .Visible = xlSheetVisible
                .Activate
                lrow = Application.Match(CLng(Date), .Range("B:B"), 0)
               If Not IsError(lrow) Then .Cells(CLng(lrow), 1).Activate
            End If
        End With

To manage the error (date not found), Variable lrow will need to be declared as Variant data type

Dave
 
Upvote 0
another option:-
Code:
  Lrow = Application.WorksheetFunction.Match(CDbl(DateValue(Date)), .Range("B:B"), 0)
 
Last edited:
Upvote 0
That is great! Thanks folks, I appreciate the choice. Both were practical and educational!
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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