I'm trying to use noMatch in Excel VBA code.
I have a spreadsheet where a "PackNum" is compared to an Access recordset (query).
When there is a match it inputs the data in Excel.
When however there is no match it grabs the first record.
For i = 2 To lrow
UpSAddPool.FindFirst ("[Packnum]= '" & Adds.Range("A" & i).Value & "'")
If Adds.Range("A" & i).Value <> "" Then
Adds.Range("C" & i).Value = UpSAddPool.Fields("[Year]").Value
Adds.Range("D" & i).Value = UpSAddPool.Fields("[Catid]").Value
Else
End If
Next i
I'd like if there is no match to call out that there is no match.
Code I tried.
The line If UpSAddPool.FindFirst("[Packnum]= '" & Adds.Range("A" & i).Value & "'").NoMatch is going to error.
For i = 2 To lrow
If UpSAddPool.FindFirst("[Packnum]= '" & Adds.Range("A" & i).Value & "'").NoMatch Then
Adds.Range("D" & i).Value = "No match found"
Adds.Range("D" & i).Value = "No match found"
Else
UpSAddPool.FindFirst ("[Packnum]= '" & Adds.Range("A" & i).Value & "'")
If Adds.Range("A" & i).Value <> "" Then
Adds.Range("C" & i).Value = UpSAddPool.Fields("[Year]").Value
Adds.Range("D" & i).Value = UpSAddPool.Fields("[Catid]").Value
Else
End If
End If
Next i
UpSAddPool.FindFirst(criteria). ThenIf not (UpSAddPool.NoMatch) then ...action ..End If.ISee doc (learn.microsoft.com/ru-ru/office/client-developer/access/…)Excel?