SUMPRODUCT to compare ranges

Phil Smith

Active Member
Joined
Aug 13, 2004
Messages
285
Office Version
  1. 365
Platform
  1. Mobile
After much headbanging and lots of reworded web searches, I have come up with the following formula,

=IF(MATCH("End",A:A)=16,"COVER",IF(SUMPRODUCT(--(B13:B100=Stations))>0,"RUNNING","DEPOT"))

only for it to produce an #N/A error.

I got the SUMPRODUCT part of formula from [url]https://exceljet.net/formula/range-contains-one-of-many-values
[/URL]
The first part, IF(MATCH("End",A:A)=16 works absolutely fine.

The last part, IF(SUMPRODUCT(--(B13:B100=Stations))>0,"RUNNING","DEPOT")) , is where it throws up the #N/A error

I couldn't work out how to reference a dynamic range for column B using MATCH("End",A:A) to find the final row. Therefore I have used a static range of B13:B100 will capture more than enough data to make a comparison to my named range, "Stations".

If there is ANY match at all between the data in B13:B100 and the named range "Stations", then the cell should show "RUNNING", otherwise "DEPOT".

Can anyone enlighten me to what is causing the error and how to rectify it?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Re: Help requested with SUMPRODUCT to compare ranges

Hi,

I imagine the most likely cause is that you've set up Stations as a vertical range, as opposed to a horizontal one.

B13:B100 and Stations need to be orthogonal to each other; since the former is clearly a vertical range, the latter needs to be a horizontal range.

Regards
 
Upvote 0
Re: Help requested with SUMPRODUCT to compare ranges

Thank you XOR LX. I have now learnt two things.

One, that the two ranges being compared need to be orthogonal.
Two, as a result of your post, that orthogonal means at right angles!

I will make those changes tomorrow - at work on a late shift now - and I will let you know.

Thank you!
 
Upvote 0
Re: Help requested with SUMPRODUCT to compare ranges

Hi XOR LX. It worked like a dream. Thank you so much!
:beerchug:
 
Upvote 0
Re: Help requested with SUMPRODUCT to compare ranges

Glad to hear it!

And cheers to you too!
:beerchug:
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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