Error Using Match ... Unable To Get Match Property

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 ...

Rich (BB code):
Private Sub uf9e_submit_Click()
    
    Dim qdate As Date
    Dim wsh_tab As String
    Dim ws_shours As Worksheet
    Dim LRow As Double
    
    Set ws_th = Workbooks("Sports17.xlsm").Worksheets("TEMP_HOLD")
   
    'update staff hours
    With ws_th
        qdate = .Range("F16")
        wsh_tab = .Range("A16") & "_" & .Range("C16")
    End With
    
    Set ws_shours = Workbooks("Staff_Hours.xlsx").Worksheets(wsh_tab)

    With ws_shours
            LRow = Application.WorksheetFunction.Match(qdate, .Range("B:B"), 0)
    End With
    
    
End Sub

I am trying to obtain the row number in which the (date) value of qdate occurs in column B of worksheet object ws_shours.
wsh_tab (52666_KB) is accurate, and exists in workbook Staff_Hours.xlsx. (sheet#2)
qdate = 3/21/18
The value, although formatted as ddd dd-mmm, 3/21/18 exists in worksheet 52666_KB at row 75.

The line in red is breaking the code with error: "Unable to get the match property of the WorksheetFunction class."

Is anyone able to suggest a possible cause, where I should be looking for a possible problem?
 
Last edited:

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
The error means that the date isn't being found. If you are sure it is there, try converting to a Double or Long using CDbl or CLng:

Code:
LRow = Application.WorksheetFunction.Match(CLng(qdate), .Range("B:B"), 0)
 
Upvote 0
Thank you Rory. That did the trick. Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

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