ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Unable to match property error (https://www.excelbanter.com/excel-discussion-misc-queries/160815-re-unable-match-property-error.html)

papou[_2_]

Unable to match property error
 
Hello Kenny
Try this:
If Target.Cells.Count = 1 And Target.Value < "" And Target.Column = 9 Then
On Error Resume Next
dummy = Application.WorksheetFunction.Match(Target.Value,
Worksheets("Codes").Range("B:B"), 0)
If Err < 0 Then
MsgBox "No matching value found"
Err.Clear
On Error GoTo 0
Else
Application.EnableEvents = False
Target.Value = dummy
Application.EnableEvents = True
End If

End If

HTH
Cordially
Pascal

"Kenny" a écrit dans le message de news:
...
I need some help with my code. This code works perfect except for when
someone types in the cell. When someone types in the cell it causes an
unable
to match error. What code could I use to trap the error and prehaps clear
the
cell (or open to suggestions) before the match function is used?

If Target.Cells.Count 1 Then Exit Sub
If Target.Column = 9 Then
If Target.Value = "" Then Exit Sub
Application.EnableEvents = False
Target.Value = Application.WorksheetFunction.Match(Target.Value,
Worksheets("Codes").Range("B:B"), 0)
End If
Application.EnableEvents = True





All times are GMT +1. The time now is 11:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com