Unable To Find Match In My Data

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,570
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have run into a problem with my attempt to use the Match function with VBA.

consider this code:
Rich (BB code):
Private Sub UserForm_Initialize()
    Dim qw As String
    Dim tqw As String
    Dim nRID As Double
    Dim nsvc As Long, psvcnum As Long, rwprid As Long
    Dim evtf As String, psvcdiv As String, pvrid as string
    
    Me.Caption = "TOURNAMENT SERVICE:  " & tcnt & " of " & ref
Stop
   
    trid = ridt 'rid (text)
    nRID = CDbl(trid) 'rid (number)
    nsvc = tsvcnum 'service (-#) number
    Debug.Print "Full Toun. RID: " & trid & "-" & nsvc
    
    'previous service division
    psvcnum = nsvc - 1
    If psvcnum = 0 Then
        pvrid = trid
    Else
        pvrid = trid & "-" & psvcnum
    End If
    rwprid = Application.WorksheetFunction.Match(CStr(pvrid), ws_master.Columns(1), 0)  'i used CStr to convert any numbers to string so the comparison is between two strings
    evtf = ws_master.Cells(rwprid, 5)
    psvcdiv = Split(Split(evtf, ")")(0), "(")(1)
    Me.lb_pdiv.Caption = psvcdiv

I am getting an error with the line in red ("Unable to get the Match property of the WorksheetFunction class") I am trying to find a match of string variable 'pvrid' with the mix of string ("########-#") and numbers (########) in column A of worksheet ws_master. In my stesting, pvrid = "45072004", which matches the numeric value in cell A14.

Here is the data in column A of ws_master in which I'm seeking the match.

Is anyone able to identify my error?
 
Sorry, I have been keeping
Rich (BB code):
 Application.Match(CStr(pvrid)
in the code, but CStr has to be removed

Please retry...
 
Upvote 1
Solution

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.
Yay! Winner winner chicken dinner!!
I think that did it Anthony, thank you.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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