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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
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,224,837
Messages
6,181,255
Members
453,028
Latest member
letswriteafairytale

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