countifs named range gives #VALUE error - excel

I just replaced the values within a formula and now it's value errors all the way, I'm not sure why:
old formula: =COUNTIFS(Cat,M$3,Sup,$B45)
new formula: =COUNTIFS(Cat,M$3,Client,$B45)
simply doing =COUNTIFS(Cat,M$3) and =COUNTIFS(Client,$B45) works, but I obviously need the common count of the two!
=SUMPRODUCT(COUNTIFS(Cat,M$3,Client,$B45)) also gives #value error
The named ranges work, so what is the problem?

The solution lies in making sure that the two ranges are of same length, as mentioned in the comment.
I'm hoping to mark this as complete, since voting to close did not work out, but this question has been resolved.

Related

Cell-Address with an IF Statement

I've been using =Cell("address",... to error check formulas I'm making to create a database and it's been working pretty well until I tried to scale up my index match formulas with some if statements.
I've narrowed the issue down to where I believe it's working as intended as long as the first statement in the if statement is true, yet if the calculation goes past that (even if the original formula is fine and returns a value) it will come back with #VALUE!.
EDIT: To be clear, the formula used above returns values without issue when not using the CELL-ADDRESS function involved. The formula also returns values when split up outside the IF-Statement.
I2=Valid
=CELL("address",IF($I$2="Valid",INDEX($I$2:$J$6,MATCH($U$1,$H$2:$H$6,0),MATCH($V$1,$I$1:$J$1,0)),IF($I$2="Invalid",INDEX($I$2:$J$6,MATCH($W$1,$H$2:$H$6,0),MATCH($V$1,$I$1:$J$1,0)),"Error")))
$I$2 is returned in the cell
I2=Invalid
=IF($I$2="Valid",INDEX($I$2:$J$6,MATCH($U$1,$H$2:$H$6,0),MATCH($V$1,$I$1:$J$1,0)),IF($I$2="Invalid",INDEX($I$2:$J$6,MATCH($W$1,$H$2:$H$6,0),MATCH($V$1,$I$1:$J$1,0)),"Error"))
#VALUE! is returned
Can anyone offer a fix for this or explain why it's happening and how to avoid it?
Any help would be appreciated.
Thanks!

EXCEL Averaging with multiple Criteria

I have tried 2 approaches to my problem and can't quite figure out where I'm going wrong.
=AVERAGEIFS(CALC!L:L,CALC!C:C,Consignee!A2,CALC!K:K,CALC!A:A) and =IF(AND(Consignee!A2=CALC!C:C,CALC!K:K=CALC!A:A),AVERAGE(CALC!L:L),0)
Basically I need to start with CONSIGNEE!A2, then find it's match in CALC!C:C, which I then need to check against CALC!A:A to find the ones that go with it in the same row and see if that/those cell(s) match any in CALC!K:K and then take the average of the corresponding values in CALC!L:L and average them. I hope that makes sense. I feel like I've gotten close but am missing something.
Thank you in advance for your help!
I suspect that the formula below may not be the most efficient possible but it will do the job.
=SUMPRODUCT((CALC!A:A=CALC!K:K)*(CALC!C:C=CONSIGNEE!A2),CALC!L:L)/SUMPRODUCT((CALC!A:A=CALC!K:K)*(CALC!C:C=CONSIGNEE!A2))
Edit
In my original answer a reference to L1 was erroneously left over from the formula I tested where I had L1 taking the place of CONSIGNEE!A2. I have corrected this error and believe that the formula works fine for your requirement now.
Note that there are two separate SUMPRODUCT functions which you can test each by itself, one returning the count, the other the sum. If the count = 0 a #DIV/0 error will occur. You can prevent that by embedding the formula in and IFERROR() function.

Problems with SUMIFS in Excel when using external reference

After doing a lot of research and trying various potential solutions, I am still stuck and hoping someone may be able to point me on the right track.
I am using a SUMIFS function in an Excel 2010 spreadsheet, but whilst it works when the reference spreadsheet is open, it gives a #VALUE error when the reference spreadsheet is closed.
My searching so far has identified that this is a known issue with Excel, but though I have tried various workarounds that are posted on forums, I haven't been able to make any work. I don't get a #VALUE error, but instead I get a zero.
The original formula is as follows:
=SUMIFS('P:\Performance\[All calls.xlsm]Jan 2016'!$N:$N,'P:\Performance\[All calls.xlsm]Jan 2016'!$R:$R,$B2,'P:\Performance\[All calls.xlsm]Jan 2016'!$G:$G,$C2,'P:\Performance\[All calls.xlsm]Jan 2016'!$J:$J,"pri")
As I say, this works fine when the other workbook is open (it obviously drops the "P:\Performance\" pre-fix), but not when it is closed (though it does change the reference to the full path).
So as per other suggestions, I have tried using SUMPRODUCT...
=SUMPRODUCT(--('P:\Performance\[All calls.xlsm]Jan 2016'!$R:$R=$B2),--('P:\Performance\[All calls.xlsm]Jan 2016'!$G:$G=$C2),--('P:\Performance\[All calls.xlsm]Jan 2016'!$J:$J="pri"),('P:\Performance\[All calls.xlsm]Jan 2016'!$N:$N)
However, this results in zero, which is clearly incorrect as the SUMIFS version and open workbook gives me a non-zero value.
Working through the calculation steps, I suspect it may have something to do with the reference cells themselves being based on formulae, but I'm not certain. Incidentally, I get the same result whether the reference workbook is open or closed.
Any ideas?
Thanks very much.
PS: I also looked at the Microsoft support site, but although it gives the impression that there is a workaround on the site, the hyperlink leads you back to the same place...
How to correct a #VALUE! error
OK, so first of all thanks to the two people who commented. I didn't need to take a look at the suggested "similar question", because I managed to resolve it myself.
The SUMPRODUCT solution posted elsewhere did in fact work. The issue turned out to be a strange situation with one of the columns I was referencing. On closer examination, I discovered that although the column was formatted as "short date", for some reason, some of the entries were not being recognised as such. I have no idea why this was, but when I converted the column to "number", it was obvious, as some of the dates failed to turn into date numbers. Strange, as all the entries were being created by a formula. So this was why the SUMPRODUCT formula was returning a zero very time.
Anyway, I found the solution here...
Some dates recognized as dates, some dates not recognized. Why?
I have no idea why this worked, but it did. And now the SUMPRODUCT workaround works, with the target spreadsheet closed. Maybe this will help someone else, or maybe it won't, but it does pay to check and double check the format of any cells you are referencing.

Excel: If vlookup returns specific text, countifs number of instances (multiple)

First post, but I am stuck and was hoping for some help. What I am trying to do is use a nested IF formula to determine whether the value returned by a VLOOKUP matches specific text on another sheet in the same workbook. If it does, to then use the COUNTIFS function to determine the sum of instances that specific text contained in a specific cell appears on another sheet (also in the same workbook).
One part of these formulas seems to work, but when I combine it with others, it errors and I can't figure out why.
It's probably something simple, but I'd appreciate any help. Here's the part that seems to "work"
=IF(VLOOKUP($A3,'Sheet1'!$B:$D,3,FALSE)="All",
(COUNTIFS('Sheet2'!$U:$U,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")
+
(COUNTIFS('Sheet2'!$R:$R,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")))
If I put one more parenthesis, it works as is, but seems to omit some of the "All" Vlookup results... thus why I put works in quotations above. That might be an issue with my spreadsheet though, but felt I should include in case I'm just being idiotic. Regardless, when I input two additional IF statements, it errors.
The final formula I've crafted looks like this (double spaced for ease of reading only):
=IF(VLOOKUP($A3,'Sheet1'!$B:$D,3,FALSE)="All",
(COUNTIFS('Sheet2'!$U:$U,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")
+
(COUNTIFS('Sheet2'!$R:$R,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")))),
IF((VLOOKUP($A3,'Sheet1'!$B:$D,3,FALSE)="One",
(COUNTIFS('Sheet2'!$U:$U,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")),
IF((VLOOKUP($A3,'Sheet1'!$B:$D,3,FALSE)="Two",
(COUNTIFS('Sheet2'!$R:$R,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY"),
IF((VLOOKUP($A3,'Sheet1'!$B:$D,3,FALSE)="Three",
(COUNTIFS('Sheet2'!$U:$U,'Sheet3'!$A3,'Sheet2'!$C:$C,"MM/DD/YYYY")),"0"))
Any ideas?
Thanks!
Ryan Olson
Just cleaned up some bracketing. Let me know how it goes as I didn't alter the formula otherwise.
=IF(VLOOKUP($A3,Sheet1!$B:$D,3,FALSE)="All",
COUNTIFS(Sheet2!$U:$U,Sheet3!$A3,Sheet2!$C:$C,"MM/DD/YYYY")+(COUNTIFS(Sheet2!$R:$R,Sheet3!$A3,Sheet2!$C:$C,"MM/DD/YYYY")),
IF(VLOOKUP($A3,Sheet1!$B:$D,3,FALSE)="One",
COUNTIFS(Sheet2!$U:$U,Sheet3!$A3,Sheet2!$C:$C,"MM/DD/YYYY"),
IF(VLOOKUP($A3,Sheet1!$B:$D,3,FALSE)="Two",
COUNTIFS(Sheet2!$R:$R,Sheet3!$A3,Sheet2!$C:$C,"MM/DD/YYYY"),
IF(VLOOKUP($A3,Sheet1!$B:$D,3,FALSE)="Three",
COUNTIFS(Sheet2!$U:$U,Sheet3!$A3,Sheet2!$C:$C,"MM/DD/YYYY"),"0"))))

Concatenate Formula (Getting a #REF Error)

Afternoon all :)
This is kind of a little difficult to explain but ill happily clarify where ever it is needed. Thank you for taking the time to read this post ^^ Here goes..
I am currently creating a spreadsheet that is been extracted from the database whereby I am tasked to concatenate data from 2 adjacent cells. I change the database on a frequent basis adding or removing data wherever necessary so the range of data is always different. To concatenate the two cells I use the following formula:
e.g: =IF(ISBLANK(B8&H8),"",B8&H8)
This formula works out great when im dealing with increasing amounts of data as I can simply drag the formula down as far as i want and i know that it will pick up the formula whenever I refresh the database without the need of seeing value errors when the formula ends up referring to a blank cell. The snag here (and my query as well) is if I have less data then before the formula within the last set of cells looks something like this:
e.g: =IF(ISBLANK(#REF!&#REF!),"",#REF!&#REF!)
I have dealt with #REF before in other spreadsheets whereby I simply used a ISERROR in the statement but I dont know if there is a possible way of including this within my formula. I need the ISBLANK there so I have more control and dont have to drag the formula as often.
If there is a better way around this or a way to amend the current formula Id appreciate the help :)
The only way you are going to get something like this:
=IF(ISBLANK(#REF!&#REF!),"",#REF!&#REF!)
in the formula bar is if you(or the system you are using) are somehow deleting the cells that were originally referenced. This should be avoidable. You can clear the cells referenced instead of deleting them completely - then you won't get this error - and your formulas will remain intact. Now you can certainly use the formulas provided in the comments to hide the errors - but the root of your problem seems to me to be that the errors are occuring in the first place. Good Luck.

Resources