Error in formula on Excel 2010 - excel

Well, I tried to make a formula on Excel 2010 in order to get flexible results.
The idea is to count cell written less cells empty, so the formula should be: =CONTAR(C10:C69) - CONTAR.BLANCO(C10:C[VALUE])Where the Value is 8 + the result of CONTAR(C10:C69).
The real formula actually extends more than this, but I got stuck at this step.
That being said, how can I produce the same result using Visual Basic to actualize the list every time excel is modified?
Thanks in advance!
EDIT: thank you for the correction

The best way is to use Index to return a reference to the range from C10 to C[Value]
=COUNT(C10:C69)-COUNTBLANK(C10:INDEX(C:C,8+COUNT(C10:C69)))
(I hope I have got the correct equivalent functions for Contar etc.)

Related

COUNTIF formula counts values that don't match

I'm using counting invoice numbers (text) in a table's column, but the Excel formula seems to be confusing some values.
I copied small sample of these - please refer to below:
The formulas are as follow:
=COUNTIFS(A1:A19,A1)
=COUNTIF(A1:A19,A1)
As you can see these invoice numbers differ and the results of these functions suggest as if all were the same.
I googled it for 1 hour but I didn't find such as issue as mine.
If anybody had any clue why could this behave in such way I'll be super grateful!
Rob
Each time you copy down this formula it will add 1 row to each. For example the second row of datas formula will be =COUNTIFS(A2:A20,A2). To lock these cells in the formula use $
Your formula should be =COUNTIFS(A$1:A$19,A1)
I've solved this myself:
ROOTCAUSE
Excel tried to be helpful and read these invoice numbers as actual numbers (despite these being defined already in Power Query as text)
Then, Excel fooled me and despite showing that it works on it as a string (I was evaluating the formula) it worked on it as number
Above means that it transformed exemplary "00100001010000018525" to 1.00001E+17, which cut down this to "100001010000018000" - that's the moment Excel stopped fooling around and showed that value in the formula bar.
I think I don't need to tell why countif perceived all these values as equal.
SOLUTION
I simply appended one letter after each invoice number to get e.g. "00100001010000018525a" what forces Excel to quit its gimmicks and games.
Case closed.
I suspect this is a bug in COUNTIF, or maybe by design.
However, to workaround this in the formula, without having to change your data, try adding a wild-card character:
=COUNTIF(A1:A19,"*"&A1)

Dynamically extract a list of unique values from a column range in Excel?

I found this example in an excel tutorial
The following image is my desired result. and the following formula is supposed to be able to extract the unique records dynamically. I know how to do this with VBA but i really want to make this a formula without using a macro.
=IFERROR(INDEX($B$2:$B$9, MATCH(0,COUNTIF($D$1:D1, $B$2:$B$9), 0)),"")
I have tried the above formula as given in the example link above but it returns with error. I am assuming that this worked at some point in excel however it no longer works with Excel 2016. Can someone clarify why this formula no longer works? Thank you.
Answering my own question about 5 minutes later, so i read the patch nodes on the how match changed from excel 2008 to 2016. You need to use the index rather than the count.
=IFERROR(INDEX($B$2:$B$9, MATCH(0,INDEX(COUNTIF($D$1:D1,$B$2:$B$9),0,0),0)),"0)),"")")
Recommended edit to the formula to change the value returned on error to a blank:
=IFERROR(INDEX($B$2:$B$9, MATCH(0,INDEX(COUNTIF($D$1:D1,$B$2:$B$9),0,0),0)),"")

Text instead of integer in Excel formula

I just received an Excel file from a colleague and I'm baffled by one of the formulas.
It's a Vlookup function where the column index number is equal to DTCN.
I tried looking up this formula but can't find it anywhere. Here it is:
=VLOOKUP($A15;KPI!$A$4:$AN$133;DTCN;FALSE)
What really matters:
=VLOOKUP(lookup value; table array; DTCN; range lookup)
I work in Excel 2010 and the formula works.
My question: What does DTCN do? How does it work? Can you only use in certain circumstances? ...
Thanks!
Take a look in :
Formula tab
Name Manager
you'll most probably find it there!

How to get 0 to display instead of #DIV/0 in Excel 2010

I am a novice at Excel and need some help with a formula. I have a set of cells that are the sum of a formula. They are based on information from month to month. At times this can be zero. I want to average them out and am using this formula =AVERAGE(IF(F17:Q17<>0, F17:Q17,"")). That works fine. But, I want it to display 0 if there are no values other than 0, instead it shows #DIV/0! Any ideas?
a simple way is to =if(sum(F17:Q17)=0,0,average(if(F17:Q17<>0,F17:q17,""))) there's also the 'averageifs' statement you should be using to make life simpler.
the IFERROR wrapper will take care of that problem. It's am optimized version of IF(ISERROR(formula)....
Your formula would then be
=IFERRROR(AVERAGE(IF(F17:Q17<>0, F17:Q17,"")),0)
note that this will hide all errors, so make sure your formulas work as expected first, before putting the IFERROR around them.

Trying to improve efficiency of array formula

I have a SUM array formula that has multiple nested IF statements, making it very inefficient. My formula spans over 500 rows, but here is a simple version of it:
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17>0,
IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
As you can see, the first half of the formula checks where the array is greater than zero, and if they are, it sums those in the second part of the formula.
You will notice that the same IF statement is repeated in there twice, which to me is inefficient, but is the only way I could get the correct answer.
The example data I have is as follows:
Sample Data in spreadsheet http://clients.estatemaster.net/SecureClientSite/Download/TempFiles/example.jpg
The answer should be 350 in this instance using the formula I mentioned above.
If I tried to put in a MAX statement within the array, therefore removing the test to find where it was greater than zero, so it was like this:
{=SUM(MAX(IF(B2:B6>B8:B12,B2:B6,B8:B12)-B14:B18,0))}
However, it seems like it only calculates the first row of data in each range, and it gave me the wrong answer of 70.
Does anyone know a away that I can reduce the size of the formula or make it more efficient by not needing to repeat an IF statement in there?
UPDATE
Jimmy
The MAX formula you suggested didnt actually work for all scenarios.
If i changed my sample data in rows 1 to 5 as below (showing that some of the numbers are greater than their respective cells in rows 7 to 11, while some of the numbers are lower)
Sample Data in spreadsheet http://clients.estatemaster.net/SecureClientSite/Download/TempFiles/example2.jpg
The correct answer im trying to achive is 310, however you suggested MAX formula gives an incorrect answer of 275.
Im guessing the formula needs to be an array function to give the correct answer.
Any other suggestions?
=MAX( MAX( sum(A1:A5), sum(A7:A11) ) - sum(A13:A17), 0)
A more calculation-efficient (and especially re-calculation efficient) way is to use helper columns instead of array formulae:
C1: =MAX(A1,A7)-A13
D1: =IF(C1>0,C1,0)
copy both these down 5 rows
E1: =SUM(D1:D5)
Excel will then only recalculate the formulae dependent on any changed value, rather than having to calculate all the virtual columns implied by the array formula every time any single number changes. And its doing less calculations even if you change all the numbers.
You may want to look into the VB Macro editor. In the Tools Menu, go to Macros and select Visual basic Editor. This gives a whole programming environment where you can write your own function.
VB is a simple programming language and google has all the guidebooks you need.
There, you can write a function like MySum() and have it do whatever math you really need it to, in a clear way written by yourself.
I pulled this off google, and it looks like a good guide to setting this all up.
http://office.microsoft.com/en-us/excel/HA011117011033.aspx
This seems to work:
{=SUM(IF(A1:A5>A7:A11,A1:A5-A13:A17,A7:A11-A13:A17))}
EDIT
- doesn't handle cases where subtraction ends up negative
This works - but is it more efficient???
{=SUM(IF(IF(A1:A5>A7:A11,A1:A5,A7:A11)>A13:A17,IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17,0))}
What about this?
=MAX(SUM(IF(A1:A5>A7:A11, A1:A5, A7:A11))-SUM(A13:A17), 0)
Edit:
Woops - Missed the throwing out negatives part. What about this? Not sure it it's faster...
=SUM((IF(A1:A5>A7:A11,IF(A1:A5>A13:A17,A1:A5,A13:A17),IF(A7:A11>A13:A17,A7:A11,A13:A17))-A13:A17))
Edit 2:
How does this perform for you?
=SUM((((A1:A5>A13:A17)+(A7:A11>A13:A17))>0)*(IF(A1:A5>A7:A11,A1:A5,A7:A11)-A13:A17))

Resources