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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

AgentSmith

Well-known Member
Joined
Mar 8, 2004
Messages
575
Use "CountIf" to calculate the number of matches. If that's zero then return your blank value.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,057
Messages
5,835,162
Members
430,343
Latest member
t0m_c

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
Top