Is IF(ISNUMBER(A1:A100),A1:A100,"") an array formula? If not, what is it?
I copied a list of holidays from a web site and pasted it to Excel. The original data had four columns (date, name of the holiday, weekday, note). After pasting to Excel, everything appeared in column A, like this:
date
name of the holiday
weekday
note
date
name of the holiday
.....
.....
I tried several ways to see if the data could be pasted into columns to no avail. So, I needed to extract the dates to another column. In column B, I entered this formula =IF(ISNUMBER(A1:A100),A1:A100,""). It worked to extract the dates from column A to column B.
I am not sure if it is an array formula as, unlike other array formulae, it doesn't need Ctrl-Shift-Enter. Yet, ISNUMBER usually takes a cell as the argument, not an array, and IF usually doesn't return an array.
IF and ISNUMBER are not array functions, but they can be used in array formulas.
Outside of an array formula, they accept only single input values and return single output values.
In an array formula, they can accept an array of inputs values and will return an array of outputs values.
Without pressing CTRL-SHIFT-ENTER, the formula you've specified is not an array function.
What you're seeing is the behaviour when a function that is expecting a single value is given a range and entered without pressing CTRL-SHIFT-ENTER but the input range overlaps with the row where the formula is placed.
Entering a range when a single value is expected will return the value from the range on the same row in which the formula is entered if it overlaps, otherwise it will return an error.
You are getting output only because you are placing the formula next to the rows being referenced; and it is giving the same result as if you had entered the formula normally and then filled down: i.e. putting =IF(ISNUMBER(A1),A1,"") in cell B1 and filling down.
Note that if you entered =IF(ISNUMBER(A1:A100),A1:A100,"") in cell B2 instead of cell B1 and then filled down, then the values still appear in the same row and not shifted down by a row as you might expect. Again, this is because it looks at the value in the same row just because the range overlaps with the current row.
Compare to putting =IF(ISNUMBER(A1),A1,"") in cell B2 and filling down, where you then get the values shifted down by a row as expected.
If you entered the original formula again in cell B101 (below the input range) and filled down, you get no values at all (even if there is data next to the cell) because the input range no longer overlaps the current cell. In fact, if you used the Evaluate Formula tool from the Formulas tab, you'll see that the range A1:A100 returns a #VALUE error immediately.
This behaviour is confusing and should be avoided at all costs. Only enter ranges when a function expects a range, or when an array formula is being intentionally created using CTRL-SHIFT-ENTER.
If after pasting your data to excel sheet looks like below then you can use following formula.
As shown to above screenshot user below formula to C1 cell then drag down and right as needed.
=INDIRECT("A"&(ROW()-1)*4+COLUMNS($A$1:A$1))
This formula will produce 0 (zero) for empty cells. To hide zero (0) use a IF() condition like below.
=IF(INDIRECT("A"&(ROW()-1)*4+COLUMNS($A$1:A$1))=0,"",INDIRECT("A"&(ROW()-1)*4+COLUMNS($A$1:A$1)))
Related
Cell A1 is empty, Cell A2 contains "test".
When creating an array formula in cell B1 like this:
{=MATCH(FALSE,ISBLANK(INDIRECT("a1:a2")),0)}
it produces the correct result "2" since the cell A2 contains a non-blank value.
However when creating an array formula in cell C1 which gets row number using the row(a2) function, it results in "1".
={MATCH(FALSE,ISBLANK(INDIRECT("a1:a"&row(a2))),0)}
How can the second formula be modified to use the row(a2) function and get the same results as the first formula, "2" instead of "1"?
Seems like it should work since row(a2) returns 2 so the address string ends up being "a1:a2", same as in the first formula. The point of this is to make the range it searches be dynamic based on the starting row 1 and ending at row(a2) so that if, for example, five rows are inserted between rows 1 and 2, then the a1:a2 range will automatically adjust to a1:a7.
Note these are "array formulas" and need to be entered using ctrl-shift-enter instead of just enter.
I am trying to figure an Excel formula and Google is not helping.
I almost have what I am trying to do, but need a 'dummy' column where I do the math in the column cells.
What this means:
1) What I have working:
Cell A1, with math formula (I wish to delete this 'dummy' cell and incorporate this into the formula in Cell B1, see further explanation below)
=SUM((6.75*1)+(5.73*2)+3)
Cell B1, with value from Cell A1 but limited to an integer less than or equal to 80
=IF(SUM(A1)>80, 80, SUM(A1))
Cell C1, with a value looking at Cell B1 and entering in this cell either 0 or any integer greater than 80
=IF(SUM(A1)>80,SUM(A1)-80,"0")
Note: This works perfectly, I change any values in the Cell A1 formula and it correctly reflects in Cells B1 & C1.
2) The missing piece:
I would like to combine the two formulas above in cells A1 & B1 into one cell, and still have the same results described above for each of the cells.
To articulate this another way is:
have a cell with a math formula,
calculate the results of that formula, and then,
enter back in the same cell that formulas results,
with the condition of 'less than or equal to 80'
while a formula in an adjacent cell is dependent on the calculated, but un-printed, value of the first cell.
As an example:
Using only Cells A1 and B1 in a spreadsheet, and combining the above working formulas (which do not work for me in Excel), it would look like this:
Cell A1:
=IF(SUM((6.75*10)+(5.73*7)+8.5)>80, 80, SUM(B21))
Note: Cell A1 formula from above, =SUM((6.75*1)+(5.73*2)+3), combined with Cell B1 formula from above, =IF(SUM(A1)>80, 80, SUM(A1)) (with the Cell A1 formula replacing both 'A1' values in the Cell B1 formula).
Cell B1:
=IF(SUM(A1)>80,SUM(A1)-80,"0")
Note: Identical to the Cell C1 formula above.
Is it possible to do this, calculate the results of a cell's formula, while a formula in an adjacent cell is dependent on the calculated, but un-printed, value of that first cell?
I realize writing this out, it's more complicated than I originally anticipated, which explains why Google wasn't getting me anywhere.
Thanks for any hints.
Phil
Strictly speaking, this is not possible. A cell has only 1 value and that is the result of all calculations. The IF statement is not hiding the value of the cell. It is changing the value.
A formula to another cell can only use the final value of the cell. It can't extract part of the formula in the other cell. There's no way for Excel to know which part to extract, even if there's only a single calculation in an IF statement.
That said, there is a different workaround possible in your case... and that is to change how your value is displayed through custom formatting. Formulas change the value of cells, whereas formatting changes how those values are displayed.
Place your formula in cell A1: =6.75*10+5.73*7+3
Right click on cell A1 and select Format Cells...
Make sure you're on the Number Tab
In the Category column, select Custom
Enter this formula in the Type box: [>80]"80";[<=80]General
Enter this formula in B1:=IF(A1>80,A1-80,0)
Check that the number format of B1 is still "General" or "Number"
The result is A1 has calculated and stored the actual value, but displays the text string "80" if it's value is above 80. You can then use the actual value from A1 in other formulas.
NOTE: This type of custom formatting is extremely poor practice as it can become very confusing and very error prone. The value of the cell is different to what it is showing and if other users are unaware, creating new formulas referring to the affected cell can unwittingly produce incorrect and/or unexpected results.
In particular, Excel tries to be helpful and can automatically copy the formatting from one cell to another if it is next to the original cell or if it refers to only the original cell in a basic formula. Copying and pasting also copies the formatting by default. Unintentionally copying the formatting to other cells will also alter how they appear.
Also note that you don't need to put SUM() around a formula that already had the addition operators included; and Excel uses order of operations so you don't need the brackets to do multiplication before addition.
Lastly, you could also just use =MAX(A1-80,0) in B1.
Is there a formula that can be used to analyse an array (say A1:A10) and return a condense list of that same array but remove all blank cells? The only caveat is, every cell in range A1:A10 is a formula, with some resulting in "", which are visually blank but obviously the cell itself contains a formula.
In the screenshot, the data in A1 is a formula =IF(ISEVEN(ROW()),ROW(),"") so every other row will evaluate to an empty string.
The formula in C2 is the array formula
=IFERROR(INDEX(A:A,SMALL(IF($A$1:$A$10<>"",ROW($A$1:$A$10)),ROW(A1))),"")
Array formulas must be confirmed with Ctrl-Shift-Enter, unless you have an Excel version with the new Dynamic Arrays formulas.
I wish to check if a cell in say column A is empty and if it is then move the data from the next column B into it. Else nothing done.
I wish it to check 1500 rows. I tried
If(A2="",A2=B2,"") I thought I could just copy it down the column. I get a circular error reference and also then cellA2 changes to 0.
Thank you for your help.
Is this a one-time task, merging two columns of data, or something that needs to be run repeatedly?
Your formula won't work (partly) because you can't have a cell that contains both a value and a formula (to check that value), at the same time.
You could, however have a 3rd column that equals Column A, unless Column A is blank, in which case it looks at Column B.
With your example, in cell C2 you could put:
=If(A2="",B2,A2)
With your formula above, you're trying assign a value to A2 with A2=B2. Excel formulas in cells assign values to "themselves" and cannot directly affect other cells.
A formula in A2 can only affect the A2. (However, the value of a cell can indirectly affect other cells with the help of VBA or features like Conditional Formatting.)
The reason your If statement isn't giving you an error with A2=B2 is because that statement A2=B2 is comparing the value of cell A2 to B2 and returning TRUE if the cells match, and FALSE if they do not (so will always return FALSE in this case).
I have an Excel formula like this:
=SUM(SUMIF(A2:A11;{"1010";"1020"};B2:B11))
Now I need to make the formula more dynamic. Instead of changing the formula itself, I should be able to change some cell (linked in the formula). This change will be reflected in the formula.
Ex:
=SUM(SUMIF(A2:A11;D2;B2:B11))
Cell D2 should return something similar to {"1010";"1020"} in the first formula.
I tried this and it works only if in the column D I have one value (ex: 1020), but if there are two values (ex: 1010;1020) it returns 0.
This is how my table looks like:
As you can see, it shows 0 for the cell where D2 has two values; but it works when there is only one value. All the rows in column D will be like cell D2, with 2 or more values, this is why it has to be dynamic using a list in the formula.
How can this be achieved in Excel? How can I make a list from the cell?
Using multiple cells would be easier! If the formula cell is one to the right of the criteria cell, you can define a named formula (Using Name Manager) called, say, GetList, which refers to this formula:
=EVALUATE("{"&INDIRECT("RC[-1]";0)&"}")
Then your formula becomes:
=SUMPRODUCT(SUMIF(A2:A11;GetList;B2:B11))