![]() |
Worksheetfunction MATCH
Hi,
When I try the following I always get Run-time Error '1004': Unable to get the Match property of the WorksheetFunction class Workbooks.Open Filename:=filenaam, ReadOnly:=True myVar = Application.WorksheetFunction.Match(9, Worksheets(1).Range("A1:A10"), 0) MsgBox myVar What is the fault, I don't really see it. Thanks a lot in advance, Yves |
Worksheetfunction MATCH
Is there a 9 in Range A1:A10?
If not, then Match raises an error such as you describe. Sub tester1() On Error Resume Next myvar = Empty myvar = Application.WorksheetFunction.Match(9, _ Worksheets(1).Range("A1:A10"), 0) On Error GoTo 0 If myvar < Empty Then MsgBox myvar Else MsgBox "Not found" End If End Sub Might be an approach you can use. -- Regards, Tom Ogilvy "Yves Janssens" wrote in message .be... Hi, When I try the following I always get Run-time Error '1004': Unable to get the Match property of the WorksheetFunction class Workbooks.Open Filename:=filenaam, ReadOnly:=True myVar = Application.WorksheetFunction.Match(9, Worksheets(1).Range("A1:A10"), 0) MsgBox myVar What is the fault, I don't really see it. Thanks a lot in advance, Yves |
Worksheetfunction MATCH
Tom,
Thanks a lot. There indeed is no value 9 in that range. But, I never thaught it would generate this error. Thanks a lot, Yves "Tom Ogilvy" wrote in message ... Is there a 9 in Range A1:A10? If not, then Match raises an error such as you describe. Sub tester1() On Error Resume Next myvar = Empty myvar = Application.WorksheetFunction.Match(9, _ Worksheets(1).Range("A1:A10"), 0) On Error GoTo 0 If myvar < Empty Then MsgBox myvar Else MsgBox "Not found" End If End Sub Might be an approach you can use. -- Regards, Tom Ogilvy "Yves Janssens" wrote in message .be... Hi, When I try the following I always get Run-time Error '1004': Unable to get the Match property of the WorksheetFunction class Workbooks.Open Filename:=filenaam, ReadOnly:=True myVar = Application.WorksheetFunction.Match(9, Worksheets(1).Range("A1:A10"), 0) MsgBox myVar What is the fault, I don't really see it. Thanks a lot in advance, Yves |
All times are GMT +1. The time now is 10:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com