If Statement for Visible Cells Only - excel

I am creating a form that autopopulates data when another form is pasted onto the workbook. I combined numbers from 5 different cells into one cell using this formula
=TEXT(L2,IF(L2=0," ","$000,000"))&"; "&TEXT(L3,IF(L3=0," ","$000,000"))&"; "&TEXT(L4,IF(L4=0," ","$000,000"))&"; "&TEXT(L5,IF(L5=0," ","$000,000"))&"; "&TEXT(L6,IF(L6=0," ","$000,000")).
Sometimes I will need to hide 3 rows, meaning I only need 2 of the numbers combined. The problem is that it still captures the 5 numbers. Is there a way to combine the visible cells only?

If you want to skip the blank cells use TEXTJOIN():
=TEXTJOIN("; ",TRUE,if(l2:l6<>"",TEXT(L2:L6,"$000,000"),""))
Use as an array formula, confirm with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

Related

How can I pull any cells with a value greater than a number?

I asked a similar question to this here but I realized the >=1400 can be either before or after my "x".
I'm trying to look at the number of users who are on screens larger than 1400. I have my Excel sheet, and tried doing an IF statement, but because of the "x" in the middle, it's not working properly and is instead just pulling all of the cells, even the ones with screen sizes less than 1400. I want to be able to pull all cells with Screen Resolution values larger than 1400 on either the first or second number.
All of the numbers highlighted in yellow would be the ones pulled.
I've tried doing slight variations of the =IF(--LEFT(A2,SEARCH("x",A2&"x")-1)>1400,A2,"No") but I can't find the right format to narrate that I want the formula to look at both numbers on either side of the "x".
You can try this:
=IFERROR(IF(OR(VALUE(LEFT(A2,SEARCH("X",A2)-1))>=1400,VALUE(RIGHT(A2,LEN(A2)-SEARCH("X",A2)))>=1400),A2,"No"),"")
Another option with array formula:
=IF(OR(FILTERXML("<a><b>"&SUBSTITUTE(A2,"x","</b><b>")&"</b></a>","//b[1 or 2]")>1400),A2,"No")
Array formula after editing is confirmed by pressing ctrl + shift + enter
As you are using Excel365 then try below formula.
=FILTER(A2:A10,(--TRIM(LEFT(SUBSTITUTE(A2:A10,"x",REPT(" ",100)),100))>=1400)+(--TRIM(RIGHT(SUBSTITUTE(A2:A10,"x",REPT(" ",100)),100))>=1400))
Or use-
=FILTER(A2:A10,(FILTERXML("<t><s>"&SUBSTITUTE(A2:A10,"x","</s><s>")&"</s></t>","//s[1]")>=1400)+(FILTERXML("<t><s>"&SUBSTITUTE(A2:A10,"x","</s><s>")&"</s></t>","//s[2]")>=1400))
As an alternative to using a complicated formula, you could just split the data up.
Create two new columns next to column A. Then use text to columns and delimit on the “x”.
In the E column use a simple formula of
IF(OR(B2>=1400,C2>=1400),”True”,”False”)

Excel SUMPRODUCT ignore blank cells or text

Very new to Excel.
Using the following, =SUMPRODUCT(SMALL(F3:F7,{1,2,3})) to get the sum of the theee lowest cells. It works fine but gives a #Num! error if more than two cells in the range are blank or contain text.
I need those cells blank or with text to be ignored and still return the sum of the three lowest numbers.
Thanks
use:
=SUMPRODUCT(SMALL(F3:F7,ROW($ZZ1:INDEX($ZZ:$ZZ,MIN(3,COUNT(F3:F7))))))
Depending on ones version this may need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

Excel nth smallest DISTINCT value

I have a set of values, the Small function gives me the ability to get the top 5 smallest values. but it doesnt take into account duplicates. I want to only see each value once. for example:
1 2 2 3 4 5
i want to output 1,2,3,4,5 not 1,2,2,3,4
I am putting the output into 5 different columns with the formula Small(A1:A20,[1-5])
but im not sure how to tell it to only look at each distinct value in the range
If one has access to the dynamic array formulas (currently only available to office 365 insiders) one can just put this in the first cell and the results will spill across:
=SMALL(UNIQUE(A:A),SEQUENCE(,5))
Other wise we need to use some array formula in a specific manner.
We must have something besides a number in the cell directly preceding where we put the formula in the first cell. So if I am putting the formula in C1, B1 must not contain one of the numbers as we need to refer to it.
Put this in C1:
=SMALL(IF(COUNTIF($B$1:B$1,$A$1:$A$20)=0,$A$1:$A$20),1)
Being an array formula it must be confirmed with Ctrl-Shift-enter instead of Enter when exiting edit mode. Then copy over 5 columns.
If one cannot leave the cell B1 without a number then we must get the array another way:
Put this array formula in the first cell:
=SMALL(INDEX($A:$A,N(IF({1},MODE.MULT(IF(MATCH($A$1:$A$20,$A:$A,0)=ROW($A$1:$A$20),ROW($A$1:$A$20)*{1,1}))))),COLUMN(A:A))
Being an array formula it must be confirmed with Ctrl-Shift-enter instead of Enter when exiting edit mode. Then copy over 5 columns.
Here is another option and in single formula
Assume your data 1 2 2 3 4 5 put in A1:A6
B1, left blank
In C1, formula copied cross right until blank
=IFERROR(1/(1/AGGREGATE(15,6,$A$1:$A$20/($A$1:$A$20>B1),1)),"")
Edit : AGGREGATE is a function for Excel 2010 or above
Here is another option:
Formula in C1:
=SMALL($A:$A,COUNTIF($A:$A,"<="&B1)+1)
Drag right...

How to declare a two-dimensional array by one cell formula?

In Excel it is pretty simple, for example
={1,2,3,4;5,6,7,8} gives us 2 rows in 4 columns.
But when I try similar in Google Spreadsheet, it fails.
EDIT: See comments below where the language version issue was revealed.
Nearly the same syntax, but different entry methods:
Excel
Hi-light a block of cells and array enter:
={1,2,3,4,5,6,7,8}
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
Google Sheets
Select a single cell and enter:
={1,2,3,4,5,6,7,8}
and the extension to the other cells occurs automatically:
Same is true for 2-D arrays:
If you are using Google Sheets, remember to leave enough empty cells to the right and below to hold the result.

How to calculate count of text?

I have put a condition for few cells in an excel as Pass and Fail.
Say there are 10 cells where one can select Pass/Fail. Now i need to calculate number of Pass and Number of Fail selected and the count needs to be displayed in another sheet.
Eg: In the 10 cells, User would have selected 7 Pass and 3 Fail. I need to display this count in another tab as 7 and 3.
Can someone help me with the formula to do this?
It's easy:
=COUNTIF(A1:A10,"Pass")
=COUNTIF(A1:A10,"Fail")
Another option for doing this is to use an array formula.
Something like this:
{=SUM(IF(A1:A10="Pass",1,0))}
Or in R1C1 mode:
{=SUM(IF(R1C1:R10C1="Pass",1,0))}
It is very important to enter these formulas holding down the CNTL+SHFT keys together when hitting ENTER. That's what makes an array formula work.
The advantage with this type of formula is you can make it quite a lot more complex than a simple COUNTIF.
If you want to display it in single cell in different sheet you can use this formula using the concatenate method(&)
'=COUNTIF(Sheet1!A1:A10,"Pass")&" Pass "& COUNTIF(Sheet1!A1:A10,"Fail")&" Fail"
Will result to:
7 Pass 3 Fail
Just change the name of the Sheet or the location of the data, sampled is located in A1 to A10 and on Sheet1
If you want it in different cells,
=COUNTIF(Sheet1!A1:A10,"Pass")
=COUNTIF(Sheet1!A1:A10,"Fail")
Will result to:
7
3
Hope that helps.
The simplest method is to use the COUNTIF function like so:
=COUNTIF(Sheet1!A1:A10,"Pass")
=COUNTIF(Sheet1!A1:A10,"Fail")
This assumes the sheet containing the data is called Sheet1

Resources