Use formula to sum cells which is reference of another cell - excel

Use formula to sum cells which is reference of another cell
My requirement:
Note: Inside bracket is the formula that particular cell holds
A1(=Sheet1!A1) ==> 6
A2(=Sheet1A2) ==> 2
A3(=Sheet1!A3) ==> 2
A4 (=SUM(A1:A3)) ==> 0 (is what I am getting) but I need A4=10
Help me out with this.

As mentioned by #Scott, one of your cells probably contains a number stored as text.
To check try either selecting all the cells and setting the format or troubleshoot which cell(s) is(are) causing the problem.
=SUM(VALUE(A1),VALUE(A2),VALUE(A3))
This will convert each cell to a numeric value. If that works then start swapping out the value function for just the cell reference (e.g. -Value(A1) becomes simply A1) and see which cell breaks the sum function. Once you find that cell you can wrap whatever formula is in that cell in the value function to force it to store the numeric value.

Related

Conditional Formatting Depending on Text In Separate Cells in Excel

I'm trying to have one column change color (individual cells in that column, rather) depending on if there is text in a different cell in the same row. I've tried using something along the lines of =IF(($B1<>""), TRUE, FALSE) and that works, but when I try to copy that formatting to the rest of the column, the cell number that the formula references stays the same, so every cell in column A will reference cell B1 instead of changing the reference cell to B2, B3, etc... on down the column.
The problem with your formula i'm assuming is the $ sign which is an absolute reference. So if you use $B1 in your formula, you're saying that you need to always compare against the value in column B.
using this formula should probably work for you:
=IF(B1<>"", TRUE, FALSE)
But it also depends on the range that you're applying this conditional-format on.
TIP:
You don't even have to use the IF function, B1<>"" returns TRUE or FASLE by default.

Is it possible to use arithmetic formulae to use as cell references in Excel (without VBA)?

Assume cell A1 contains value 10 and A2 contains value 20. Then, I need to way to refer to the cell on column A and line 10 + 20. Something that could be imagined as A{A1+A2}. Is there a way to preceed so?
Use the INDEX Function:
=INDEX(A:A,A1+A2)

Get Count of Cells used in Excel Formula

I want to get the count of cells used in an excel function.
For example say I have a sum function ='CV'!D11+Farmer!D11+'County'!D11+Rt!D11+WT!D11+'Country'!D11
I need a function that will tell me how many cells were used to get the total sum. In this case it is 6. The tricky part is if one of the cells used is blank I do not want it counted. For instance say cell D11 on the Farmer sheet is blank I do not want it counted in the total. So the total should be 5.
Use COUNT:
=COUNT('CV'!D11,Farmer!D11,'County'!D11,Rt!D11,WT!D11,'Country'!D11)
It will only count the cell if it has a number
You should really try to collate all your data in to a single sheet before running calculations. For the sake of example, I'll assume you have it in the range A1:A5, then you can add handling of the various cases using array formulas:
Get the count of non-empty cells (the ISBLANK function is untrustworthy in my experience): {SUM(IF(LEN(A1:A5)>0,1,0))}
Get the sum of those cells: SUM(A1:A5)
(must use Ctrl+Shift+Enter to enter the formula as an array formula, you will know it worked if the formula shows like {IF(...)} with the curly brackets)
Because blank/missing values are treated implicitly as 0 in the SUM function, this case is simple. If you have other validations then you'd have to write an array formula for the summation as well. For example, only including numbers between a min and max threshold (e.g. if you want to exclude outliers):
{SUM(IF(AND(A1:A5 >= yourMinValue, A1:A5 < yourMaxValue), A1:A5, 0)}.
If I understand your question correctly, you want to literately count the number of cells used in a formula which in your example is summing 6 values from 6 different locations.
I used the following example to demonstrate my solution:
The sum of =A1+B1+C1+D1+E1+F1 is 10 where cell C1 has a 0 value in it but cell E1 is blank.
Using the following array formula I was able to count the number of cells that have a value other than 0:
=SUMPRODUCT(IFERROR(ABS(N(INDIRECT(TRIM(MID(SUBSTITUTE(RIGHT(FORMULATEXT(A3),LEN(FORMULATEXT(A3))-1),"+",REPT(" ",100)),100*ROW(INDIRECT("1:"&LEN(FORMULATEXT(A3))))-99,100)))))>0,0)*1)
Please note you MUST press Ctrl+Shift+Enter upon finishing the formula in the formula bar otherwise they will not function correctly.
The logic is to use a combination of TRIM+MID+SUBSTITUTE+RIGHT+FORMULATEXT+REPT+ROW+INDIRECT to extract the cell addresses from the original formula, then use INDIRECT to convert the cell address into the values stored in those cells, then use a combination of IFERROR+ABS+N to find out if any of these values are not 0, and lastly use SUMPRODUCT to add up all the TRUE results.
It is obvious that there are a couple limitations of my solution:
If your actual formula is not strictly in the form of A+B+C+D+E+F, then my SUBSTITUTE part of formula will need further modification;
The formula will treat cells containing 0 as blank and does not include them in the count.
Let me know if you have any questions. Cheers :)

Get Excel cell relative reference into a cell

I am trying to find how to get an excel formula to get a cell's relative reference into a cell.
A formula that would be like =getcellreference(B2) and then has B2 as the output.
Nothing complicated but i could not find a simple solution.
You can use CELL():
=CELL("address",B2)
For formatting to literally show B2 instead of the absolute reference, you can do:
=SUBSTITUTE(CELL("address",B2),"$","")
If all you are trying to do is output a cell reference that you manually input, then all you need to do is:
="B2"
or
B2 (no equals sign)
You can use the ADDRESS function to obtain the address of a cell in a worksheet, given specified row and column numbers
ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])
So for cell B2, you will need to put =ADDRESS(2,2) where the first 2 stands for the row number and 2nd is for column B.

Comparing cells with using Excel LEFT Function

I wanted to compare value in cell A1 and B1.
However, sometimes PC give different value as cell B1.
Initial code I've been writing is as below in cell C1:
=IF(ISERROR(MATCH(A1,$B$1:$B$5,0)),"","Duplicate")
This code only compare exact value. Thus, I'm trying to add LEFT Function into function above:
=IF(ISERROR(MATCH(Left(A1,8),$B$1:$B$5,0)),"","Duplicate")
But above function only count character in A1 only. How do I add LEFT(B1,8) to also read value in cell B1?
Thanks.
Regards,
Zaiem
Maybe what you would like is:
=IF(MAX(IFERROR(FIND(LEFT(A$1,8),B$1:B$5),""))=1,"Duplicate","")
entered with Ctrl+Shift+Enter

Resources