I'm trying to count cells that start with a certain date equal to a cell using sumproduct which works fine unless the array includes blanks.
Through a lot of google searches and stackoverflow searches, i've managed to come up with the below code, i've tried at least 20-25 variants with none giving the intended result, including CSE/array formulas
Evaluating the formula shows that the second array is keeping the blanks and giving a #Value error which i can't remove from the array.
=SUMPRODUCT((BB3:BB33)<>"",--(DAY(BB3:BB33)=DAY(A38)))
A38 is in the format 11/09.
Range BB3:BB33 is dates (with times unsplit due to how data is pulled)
11/09/2019 08:14
11/09/2019 08:14
10/09/2019 23:20
10/09/2019 23:20
10/09/2019 23:20
10/09/2019 23:20
10/09/2019 23:20
10/09/2019 23:20
BLANK
BLANK
etc, etc.
the output should be 2 for A38 which when the range only includes non-blanks is correct but the blanks override the result to #Value
Any help would be greatly appreciated!
Thanks!
I've FINALLY managed to solve this with a much simpler solution (After many many attempts). This ignores the blanks completely which were the cells causing issues for sumproduct.
=COUNTIFS(BB3:BB33,">"&DATEVALUE(A38))
Doesn't require CSE.
Related
I am having an issue with the INDEX MATCH formula. This is the formula below. My problem is the cell I am trying to match is 15 characters but the target cell is 18 characters. I tried the LEFT function but it's returning N/A.
Can anyone please help me with my formula? I don't use excel a lot.
=INDEX('[HOCS LIST.xlsx]Sheet1'!$B$2:$B$70541,MATCH(LEFT(F3,14),'[HOCS LIST.xlsx]Sheet1'!$A$2:$A$70541,0))
The Target spreadsheet as you can see is 18 characters but the first 15 are exactly the same. I want my formula to look for the first 15, not the whole 18.
Thank you
I've tried the LEFT function to look for 15 characters but I still get the N/A result.
I think you just have the columns flipped... You don't want the first 15 characters of column F. From the screenshot that is the shorter cell, you want to compare it to column A...
=INDEX('[HOCS LIST.xlsx]Sheet1'!$A:$B,MATCH($F3,LEFT('[HOCS LIST.xlsx]Sheet1'!$A:$A),0),2)
That being said I adjusted your index to include BOTH columns A:B along with adjusting it to return column 2 (B) assuming that's what you are looking for?
I came across an interesting issue today that I can't seem to find a solution on the internet for. I have a formula that looks like this:
=IFERROR(INDEX(Table,MATCH(1,(Table,Col1=A1)*(Col2= B1),0),3),"NOPE")
The formula works correctly, but in some cases where the return value is 0 (i.e. the value is blank in column 3 that is being returned, but there are appropriate matches in Col1 and Col2) something wonky happens. When I execute the formula the 0 value shows briefly and then slowly fades to blank. When you copy the cell and try to paste the value plain text it is also blank. What concerns me is this only happens in some cases, other cells have a 0 value returned and it remains in the cell.
My best guess is it has something to do with the cell formatting (even though it is set to general for all cells), but I'm at a loss. This doesn't really impact the performance of the spreadsheet, but it looks sloppy having some cells with 0's and others that are blank even though they indicate the same result.
Any help would be greatly appreciated.
Edit 2: Changed the values from numeric to text 1=A, 2=B, etc. and this did not solve the problem, there are still some stubborn cells with the issue described above.
EDIT 3: Haven't had any luck fixing the issue. My work around for the time being is IF(original formula)= 0,"", (original formula)) for uniformity so empty results are returned as a blank and not a 0 or blank. Strangely, I tried IF(original formula)= 0,0, (original formula)) and the zero still faded in some cells.
I have had this happen before. I suspect you might be using Office 365, and a recent update threw Excel on this one. What I got to work is to create a new worksheet, format the column in question from the beginning as a number (or currency), and then enter the formula into the cell (do not copy from the other worksheet). Paste this formula down and it should be a consistent "0" or "-".
I also have found that it helps to save the file as a ".xlsb" for larger files. This tends to add stability in all areas.
I have successfully troubleshot VLOOKUP issues for years but this one has me stumped. I'm referencing between lists by full names (John Doe, for example) but getting #N/A. I've already tried TRIM (didn't change anything and by inspection I can see that there are no extra spaces in the original data anyway). I also tried Text-to-Columns, which in the past has magically fixed my VLOOKUPs but not now. I also tried a Stack Overflow suggestion to check each pair of names using the CODE function but both have the same numerical Code.
I've attached a sample file containing the issue.
Vlookup Excel File
The problem is that space in between Paul and Casey is not a normal space in B3.
To illustrate I put This in F1:
=CODE(MID($A$1,ROW(1:1),1))
And in G1:
=CODE(MID($B$3,ROW(1:1),1))
And copied down.
32 is what we want but the space in B3 is 160
To fix this we can substitute the 160 for 32:
=VLOOKUP(SUBSTITUTE(B3,CHAR(160),CHAR(32)),A1,1,0)
I have a worksheet looking at football results. I have inserted a formula to discover the longest sequence of blank cells which indicates to me how many games between either wins/draws/defeats. Taking wins as an example which I have in Column H, this formula (The cells in Column H contain either a 1 or are blank)
{=MAX(FREQUENCY(IF(H1:H5077="", ROW(H1:H5077)), IF(H1:H5077=1, ROW(H1:H5077))))}
has told me that the longest sequence without a win for the selected team was 19 matches. That formula and result on my workbook is in cell H5094
What I want to do is discover where amongst 5000+ matches that sequence is?
I've tried this formula which I've used before in an adjacent column and copied down
=IF(COUNTIF(OFFSET(H2,0,0,$H$5094,1),1)=$H$5094,"here","")
however it hasn't worked. I think the mistake is within the formula, possibly the 0 and 1 but I don't know how to put it right, I've tried several variations.
Any help much appreciated.
The method looks fine to me, but the easiest way would be to use COUNTBLANK instead of COUNTIF, so the formula would be:-
=IF(COUNTBLANK(OFFSET(H2,0,0,$H$5094,1))=$H$5094,"here","")
or alternatively
=IF(COUNTIF(OFFSET(H2,0,0,$H$5094,1),"")=$H$5094,"here","")
I noticed that you could get some extra 'heres' if the longest sequence came at the end of the range, but you could fix it by putting a '1' in H5078.
When using 0.1025 as the lookup_value for VLOOKUP or MATCH functions, the formulas only seem to work when the value is hardcoded as a number. If referencing the value from another cell, the formulas produce #N/A errors. Strangely, the problem seems to be eliminated if ROUND is applied to the reference cell first. Another solution that works is if the cell value is first multiplied by 100 then by it's reciprocal and yet 2 or 5 does not work. Similar behaviour happens with 0.0875, 0.1175 and 0.1425.
The problem is exemplified by the formulas shown here.
Copy below and paste to cell A1.
0.1025 =CEILING(A3,0.0025) =A1=B1
0.14821 =VLOOKUP(B1,A:B,2,0)
0.10163 =MATCH(B1,A:A,0)
=MATCH(0.1025,A:A,0)
=MATCH(ROUND(B1,4),A:A,0)
=MATCH(10.25/100,A:A,0)
=MATCH((B1*100)/100,A:A,0)
=MATCH((B1*2)/2,A:A,0)
Above produces results as shown below.
0.1025 0.1025 TRUE
0.14821 #N/A
0.10163 #N/A
1
1
1
1
#N/A
Why?
My guess (because I've run into this issue myself a myriad of times and your solution is the one we used) it has to do with precision values in Excel. Anytime I deal with decimals I am forced to "test" if Excel is treating my values as they are displayed or if micro-values are secretly there, too.
We use the ROUND(), MROUND(), CEILING() and FLOOR() functions to precisely "reset" values before they are further used for this very reason.
0.1025 may really be that, unless you start formatting that cell for 8-10 decimal values... do more numbers appear?
You can frustratingly duplicate this very easily. In A1, type 0.1025, then in A2 put 0.1026.
Now try the formula =EXACT(0.0001, A2-A1).
The result will be FALSE.
If you run the EVALUATE FORMULA function on that cell, you will see a micro-value causes the math to be a value of 0.000100000000000003 instead of just 0.0001.
So, rounding tools correct the displayed value to an ACTUAL value, and that's why we do it. Yah, Excel!