Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I have run into a problem with my attempt to use the Match function with VBA.
consider this code:
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?
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?