How to detect if there is no match?

nicholasho

New Member
Joined
Oct 10, 2005
Messages
6
Hi,

I am writing a macro to retreive values from a sheet based on values of another sheet. The following statement is trying to do the work:

Set RangeOne = Worksheets("Sheet5").Range("AX2:AX2503")
.
.
Agreement = Application.WorksheetFunction.Index( RangeOne, Application.WorksheetFunction.Match(Order, Worksheets("Sheet5".Range("A2:A2503"), 0))

Current problem is that run time error will issue if there is no match of Order value. I like to assign blank value to Agrement if Order value is not found.

How can I detect the error situation?

Thanks and Regards
Nick
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Use "CountIf" to calculate the number of matches. If that's zero then return your blank value.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,936
Members
449,094
Latest member
teemeren

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