I have the following code in a sheet, it looks at a range of cells and for those containing "READING" in Column BS it looks to Column CJ to see if its value is less than the value 1. The problem is that the word "READING" could be in one of 8 co
The problem is that the word "READING" could be in one of 8 columns. (BS to BZ)=SUMPRODUCT(--($BS$6:$BS$45="READING"),--(CJ$6:CJ$45=""))
I've tried using the following code but it returns #VALUE! Has anybody got any idea how I can make this work.
=SUMPRODUCT(--($BS$6:$BZ$45="READING"),--(CJ$6:CJ$45=""))
Last edited by BobTheRocker; 01-26-2011 at 11:09 AM. Reason: Solved
Perhaps:
The above assumes that should READING occur more than once per row you wish to count as 1 instance only - if not:=SUMPRODUCT(ISNUMBER(MATCH("READING",$BS$6:$BZ$45,0))*(CJ$6:CJ$45=""))
The 2nd is in essence an adaptation of your approach - note with Arrays of different dimensions (1x8 & 1x1) you must multiply the Arrays together as opposed to coercing each separately via double unary (#VALUE!)=SUMPRODUCT(($BS$6:$BZ$45="READING")*(CJ$6:CJ$45=""))
See the link in my sig. to Bob Phillips' white paper for more info. on SUMPRODUCT
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Thank you for your reply, I tried both but both returned zero when they should return 1. The first code you mentioned would be preferable as I would like to record several instances of reading as only 1 (though this is not essential).
this should return 1 when it matches the word READING in a column BS to BZ and in the corresponding row for column CJ it sees a blank.=SUMPRODUCT(ISNUMBER(MATCH("READING",$BS$6:$BZ$45,0))*(CJ$6:CJ$45=""))
I tested it again using just one column (BS) and this works for one column but the word could appear in 1 of 8 columns.
Any ideas what I'm doing wrong?=SUMPRODUCT(--($BS$6:$BS$45="READING"),--(CJ$6:CJ$45=""))
You're not doing anything wrong - the example I gave you won't work - simple as ! Ooops.
obviously if you could create a single concatenation string on each row (aping above) then that would simplify the SUMPRODUCT=SUMPRODUCT(ISNUMBER(SEARCH("^READING^","^"&$BS$6:$BS$45&"^"&$BT$6:$BT$45&"^"&$BU$6:$BU$45&"^"&$BV$6:$BV$45&"^"&$BU$6:$BU$45&"^"&$BV$6:$BV$45&"^"&$BW$6:$BW$45&"^"&$BX$6:$BX$45&"^"&$BY$6:$BY$45&"^"&$BZ$6:$BZ$45&"^"))*(CJ$6:CJ$45=""))
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Thanks very much for your help and how strange because just tried those formula with another example in a smaller worksheet and they work, so I tried them again in my main project and indeed both examples below work based on you coding.
=SUMPRODUCT((BS6:BZ45="READING")*(CJ117:CJ156<1))I will try your third example as well and see what that throws up. Thank you=SUMPRODUCT((BS8:BZ45="READING")*(CJ8:CJ45=""))
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks