using a cell from another sheet as reference - excel

I wrote a formula which calculates the inputs in "Sheet2" which is below. So J4 is a cell of Sheet2:
=((COUNTIF((INDIRECT(ADDRESS(ROW(J4);COLUMN(J4))&":J"&
(MIN(IF(A4:A107="";ROW(A4:A107))))));"
<>"&""))-1)/((COUNTIF((INDIRECT(ADDRESS(ROW(J4);COLUMN(J4))&":J"&
(MIN(IF(A4:A107="";ROW(A4:A107))))));"<>0"))-1)
Now I want to write this formula to a cell in Sheet1.It means i should reference the Sheet2 for calculating the formula.
Can anyone help me with referencing?
EDIT: I still am without solution for this issue. Can anyone suggest me something new then in the comments?

Looking at your formula, it seems you want to evaluate ratio of:
Count non-blank cells in column J where column A is also non-blank.
Divide this count by count of non-zero cells in column J where column A is non-blank.
If yes then test following formula and see if it works per your needs:
=COUNTIFS(Sheet2!A4:A107,"<>",Sheet2!J4:J107,"<>")/COUNTIFS(Sheet2!A4:A107,"<>",Sheet2!J4:J107,"<>0")
Make sure you change argument separators.
Edit
In that case, you need to use following array formula (CTRL+SHIFT+ENTER) and change argument separators.
=COUNTIFS(Sheet2!A4:INDEX(Sheet2!A4:A107,MIN(IF(Sheet2!A4:A107="",ROW(Sheet2!A4:A107)))),"<>",Sheet2!J4:INDEX(Sheet2!J4:J107,MIN(IF(Sheet2!A4:A107="",ROW(Sheet2!A4:A107)))),"<>")/COUNTIFS(Sheet2!A4:INDEX(Sheet2!A4:A107,MIN(IF(Sheet2!A4:A107="",ROW(Sheet2!A4:A107)))),"<>",Sheet2!J4:INDEX(Sheet2!J4:J107,MIN(IF(Sheet2!A4:A107="",ROW(Sheet2!A4:A107)))),"<>0")

Related

Problem with IF AND and Vlookup nested formula

I am trying to put a nested IF, AND and Vlookup formula. I want formula to return the value "0.17" in cell F3 if cell D3 has text "pasha" and B3 is not equal to cells mentioned in vlookup formula but its returns zero instead of showing 0.1. Please guide, TIA
=IFERROR(IF(AND(D3="Pasha",VLOOKUP(B3,G70:H78,2,0)<>B3),0.17,IF(VLOOKUP(B3,$B$69:$B$89,1,0)=B3,0.15,"")),0)
enter image description here
You may want to replace
VLOOKUP(B3,G70:H78,2,0)<>B3)
(Excel will unsuccessfully try to match B3 value with values from G column range while it contains different type of data:“Pasha”)
with
NOT(ISNUMBER(MATCH(B3,H70:H78,0)))
And feel free to adjust the second VLOOKUP accordingly.
So, how about this:
You need to to sort the vlookup() but the process for testing the conditions is there.

Get list of rows with a second non-blank value and the column header for the second non-blank occurrence

I have an Excel sheet with data represented as below:
I need to get all the sites with a second non-blank column in the site's row (except Site, of course) and also get the Column Header value.
In the example, sites B, F and G have a second Y. So the result should be:
I am not very well versed with Excel Formulas, but I have experimented a bit with INDEX and I can find the second non-blank value itself. But I can't figure out a way to return the result I require.
Using the below formula I get as far as this, but still nowhere near my expected result.
{=INDEX(B2:I2,SMALL(IF(B2:I2<>"",COLUMN(B2:I2)-COLUMN(B2)+1),2))}
Edit:
With #Harun24HR 's answer I get this new result.
Try below formula.
=INDEX($B$1:$I$1,,SMALL(IF(($B$2:$I$11="Y")*($A$2:$A$11=C14)>0,COLUMN($B$2:$I$11),""),2)-1)
May need array entry with CTRL+SHIFT+ENTER.
Edit#: As per my below screenshot I have used below formulas.
For result column in J2 cell put
=IF(COUNTIF(B2:I2,"<>")>1,ROW(),"")
In C14 put
=IFERROR(INDEX($A$1:$A$11,SMALL($J$1:$J$11,ROW(1:1))),"")
And in D14 cell put below formula.
=INDEX($A$1:$I$1,MAX(($B$2:$I$11<>"")*($A$2:$A$11=C14)*(COLUMN($B$2:$I$11))))
Please note. You no need to array entry for these formulas.
Finally I ended up solving this using a combination of the accepted answer (by #Harun24HR) and How To Extract A Dynamic List From A Data Range Based On A Criteria Without Filters In Excel
In J2 through J11, I added the formula:
{=IFERROR(INDEX($B$1:$I$1,,SMALL(IF(($B$2:$I$11<>"")*($A$2:$A$11=A2)>0,COLUMN($B$2:$I$11),""),2)-1), "")}
In A15 to A24 (same number of rows as the original range), I added the formula:
{=IFERROR(INDEX($A$2:$A$11,SMALL(IF($J$2:$J$11<>"",ROW($A$2:$A$11)),ROW(1:1))-1,1),"")}
In B15 to B24, it's a simple VLOOKUP:
=IFERROR(VLOOKUP(A15,$A$2:$J$11,10,0),"")
This way, the result table is dynamic.

Excel Nested Conditional If Formula with Binary 0 or 1 Output

I am trying to use a multi-nested conditional Excel formula properly. I think what I have is close but I'm missing something.
=IF(BF6=1,IF(AI6=AI9,IF(BC8=0, 0,1)))
I am not sure I can use AI6=AI9 to specify that the contents of these cells are identical.
Separately, I want this formula to repeat every 7 rows, so I expanded the formula to include the this function:
=IF(MOD(ROW()-1,7),"",IF(BF6=1,IF(AI6=AI9,IF(BC8=0, 0,1)))
Any advice would be appreciated.
Screenshot of problem with new formula: =IF(AND(EXACT(AI6,AI9),BF6=1,BC8=0),1,0)
Image of final formulas that work
In the end, I had to use two formulas in two consecutive cells to make it calculate correctly.
=IF(EXACT(AI6,AI9), 1,0)
=IF((AND(BB9=1, BF6=1, BF9=0)), 1, 0)
I will conquer using IF, AND and EXACT in one conditional formula some other time. Thanks for all the help!
REVISED:
From what I understand, this is what you want. Copy the following formula and paste on cell BB9 then drag the formula down to where the record ends.
=IF(MOD(ROW()-2,7),"",IF(AND(AI6=AI9,BH6=1,BH9=0),1,0))
MOD(ROW()-2,7) is to determine where the result should show. Row() means the current row, and I subtract 2 to eliminate header row and blank row on row 2. 7 is to repeat every 7 rows.

Suggest EXCEL formula to find first and second defined cell value change in a row

I need a suggestion for regular formula (no VBA/no array formulas) to do the following please:
There is the following dataset:
I need a formula going in the column A and B and returning the month of the first and the second change from 1 to 2 for each row correspondingly.
There are only 1 and 2 being used in the searchable range.
This was really a puzzle :) Please find solution W/O array formula. Make sure you put a number 1 and 2 in cells A1 and B1, because they are part of formula telling which occurrence to take.
=IFERROR(INDEX($E$1:$P$1,1,AGGREGATE(15,6,(COLUMN($E$1:$P$1)-COLUMN($E$1)+1)/($E2:$P2/$D2:$O2=2),A$1)),"")
Without array formulas and pre-calculcations it is very awkward solution
https://drive.google.com/open?id=0B44mzqKXfJYobjNuc0xQRHBaZVU
Use this file for your task. (formulas are inside)
Thank you for + my answer

How do I use an array formula over a whole column or varying range?

I have a spreadsheet that I'm importing data into. I need to find the value within a column that is closest to zero. The column contains both positive and negative values, and the value closest to zero will be used in another formula. I've found an answer using an array formula, but it will only work for a fixed range (e.g. K2:K10), and the number of records imported into my sheet will vary each time I use it.
Here's what I have so far:
=INDEX(K:K,MATCH(MIN(ABS(K:K)),ABS(K:K),0))
Is there a way to apply an array formula over an entire column and just include non-zero cells other than the column title? Or possibly just cells with numerical values? Or is it possible to control the range that it applies to?
We can dynamically find the last cell in the range by using another INDEX/MATCH formula that is not an array:
=INDEX(K:K,MATCH(1E+99,K:K))
This will find the last cell that has a number in column K.
So we now use this as the last cell in the range:
=INDEX($K$2:INDEX(K:K,MATCH(1E+99,K:K)),MATCH(MIN(ABS($K$2:INDEX(K:K,MATCH(1E+99,K:K)))),ABS($K$2:INDEX(K:K,MATCH(1E+99,K:K))),0))
And now the formula is dynamic.
This formula is still an array formula and must be confirmed with Ctrl-Shift-Enter when exiting edit mode. If done correctly then Excel will put{} around the formula.
If as you pointed out there is a chance of deleting row 2 then all the K2 references will also be deleted.
In place of K2 we can use INDEX(K:K,2) It will now always look at the second row and will not error when row 2 is erased. So use this instead:
=INDEX(INDEX(K:K,2):INDEX(K:K,MATCH(1E+99,K:K)),MATCH(MIN(ABS(INDEX(K:K,2):INDE‌​X(K:K,MATCH(1E+99,K:K)))),ABS(INDEX(K:K,2):INDEX(K:K,MATCH(1E+99,K:K))),0))
There is nothing wrong with the Offset() function in small amounts, but it is a volatile function. Which means that it will calculate EVERY TIME excel calculate whether the data to which it is dependent has changed or not.
For the benefit of anyone reading this post, I ran into another issue and found a way around it. Scott Craner's answer above worked well until I ran a macro that I had for that sheet, which would delete certain rows. If row 2 got deleted, the formula would give a #REF error, because it was trying to call $K$2.
My solution was to replace $K$2 with
OFFSET(K1,1,0)
Therefore, the complete formula would be:
=INDEX(OFFSET(K1,1,0):INDEX(K:K,MATCH(1E+99,K:K)),MATCH(MIN(ABS(OFFSET(K1,1,0):INDEX(K:K,MATCH(1E+99,K:K)))),ABS(OFFSET(K1,1,0):INDEX(K:K,MATCH(1E+99,K:K))),0))
And as Scott mentioned, remember to hit Ctrl-Shift-Enter to execute the array formula.

Resources