Check if some one field is empty - excel

in my Excel document I have 51 fields that I need to check that these fields were not empty/ I am using Excel 2003 and there is maximum 30 argument of function OR:
=IF(OR(ISBLANK(A3)=TRUE;ISBLANK(B3)=TRUE...);"Some empty field";"")
Here is my exemple, but I need to check more fields, how can I do this?

You can do this with a simple COUNTA, ie for 51 cells from A3 to AY3
=IF(COUNTA(A3:AY3)=51,"ok",51-COUNTA(A3:AY3) & "fields are empty")
footnote: =ISBLANK(A3) is the same as =ISBLANK(A3)=TRUE but is simpler

Most likely, the best is the option 4 below
Couple of options:
VBA
insert a row 4 (you will hide it afterwards) and put there these formulas:
A4: =IsBlank(A3)
B4: =OR(A4, IsBlank(B3))
and copy this formula further on, e.g. C4: =OR(B4, IsBlank(C3)), ... then, in the last cell you will have the answer
If you know that the cells should contain numbers of if this just works for you, the formula would be =(A3+0)*(B3+0) .. and you test if the result is 0. The blank plus 0 is 0
Possibly best would be for you to use this:=NOT(ISBLANK(A1))+0 and then multiply the results. ISBLANK + 0 converts the true to 1, that is =IF(NOT((ISBLANK(A3))+0) * (NOT(ISBLANK(b3))+0) ... =0, xxxxx

Related

COUNTIF if values are not in one row

Excel
A B C D E F
1 4 400
2 0
3 700
4 0
5 300
6 0
7 0
8 100
9
In the above Excel table I have values in different cells.
In cell A1 I want to count the number of cells that contain a value <> 0.
Therefore, I tried to go with this formula:
A1 = COUNTIF((D1,E2,F3,D4,D5,F6,F7,E8),0)
However, with this formula I get #VALUE!.
I assume the issue is that the array for the COUNTIF formula is not in one row.
One way of solving the issue would be to make a helper column in which I put all the values in one row but I am wondering if there is another way of doing it without any helper column?
If using a non-continuous range is a must you could use:
=SUM(COUNTIF(INDIRECT({"D1","E2","F3","D4:D5","F6:F7","E8"}),"<>0"))
Note that this is volatile!
This is a problem due to your regional settings.
By default, Excel uses the list separator defined under regional settings in Control Panel. The US English version of Excel uses a comma (,) for list separator by default, while other international versions may use a semicolon (;). Try to put a semicolon between range and condition.
A1 = COUNTIF(D1,E2,F3,D4,D5,F6,F7,E8; 0)
It's a bit more typing but if you are intent on using specific cells:
=SUM(D1<>0,E2<>0,F3<>0,D4<>0,D5<>0,F6<>0,F7<>0,E8<>0)
The D1<>0 test will return TRUE or FALSE. In the SUM() function, Excel treats TRUE as 1, and FALSE as 0. And you don't have to use INDIRECT() which can store up trouble for the future.

Calculate current streak in Excel row

I have a list of 1s and 0s in excel row ranging from B2:K2, I want to calculate the current streak of 1's in cell M2,
example dataset where streak would be 4
1 0 1 0 1 1 1 1 0
Is there a simple way of doing this? I have tried research but not been able to find anything specific.
Any help would be much appreciated.
Here is a way of doing this with just one formula, no helper columns/rows needed:
The formula used translates to:
{=MAX(FREQUENCY(IF(B1:K1=1,COLUMN(B1:K1)),IF(B1:K1=1,0,COLUMN(B1:K1))))}
Note: It's an array formula and should be entered through CtrlShiftEnter
Assuming your data is layed out horizontally like the image below, the following two formulas should do it for you.
The first cell requires a different formula as the is no cell to the left to refer to. so a simple formula to check if the first cell is one or not is entered in B2.
=--(A1=1)
The part in the bracket will either be true or false. A quirk of excel is that if you send a true or false value through a math operation it will be converted to 1 for true and 0 for false. That is why you see the double - in front. could have also done *1, /1, +0,-0 at the end.
In B2 place the following formula and copy right as needed:
=(A2+1)*(B1=1)
Basically it adds 1 to the series, then check if the number in the sequence is 1 or 0. In the event its one, it keeps the value as it is TRUE sent through the math operator *. If it is false it set the sequence back to zero by multiplying False by the math operator *.
Alternate IF
Now the above while it works and may save a few characters is not necessarily intuitive for most. The go to option would be to use an IF function. The above formulas can be replaced with the following:
A3
=IF(A1=1,1,0)
B3 ->Copied right
=IF(B1=1,A3+1,0)
Longest streak
To get the longest streak, the highest value in your helper row is what you want. You can grab this with the following formula in an empty cell.
=MAX(2:2)
=MAX(A2,I2)
If you have no other numbers in your helper row, you can use the first formula which looks in the entire row. If there are other numbers due to calculations off to the left or right as an example, then you will want to restrict your range to you data as in the second formula.
I've put those values in cells B2 to B8.
In cell C3, I've put this formula:
=IF(AND(B3=1;B2=1);C2+1;1)
Dragging this downto C8, and then take the maximum of the C column.

Return row number or true or false or value if condition is met - VBA Excel

I know this will sound odd, but is that scenario possible?
1st - I do not want to use a macro. So it has to be a formula.
Assuming I have this tree columns:
A B C
1 01-Jan-2016 05-Jan-2016 White
2 01-Feb-2016 08-Feb-2016 Yelllow
3 01-Mar-2016 09-Mar-2016 Red
Let's suppose I give this date: 03-Mar-2016. Do we have a way to return Red if that date is found on that range? Or at least return row number where that condition is met?
Use this array formula:
=INDEX($C$1:$C$3,MATCH(1,(E1>=$A$1:$A$3)*(E1<=$B$1:$B$3),0))
Being an array formula it needs to be confirmed with Ctrl _Shift_Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

Formula to return original value if specified character not found

I have two Excel sheets (let's say sheet1 and sheet2). For an example here, the values on sheet1 from R1C1 to R4C1 are 0(5), 2(6)*, 92and 44.
I want to copy just the numeric values from sheet1 to sheet2. Thus, I have this formula in R1C1 of my sheet2:
=LEFT(Sheet1!A1,SEARCH("(",Sheet1!A1)-1)
This formula returns the values on sheet2 like this:
R1C1 - 0
R2C1 - 2
R3C1 - #Value!
R4C1 - #Value!
The main issue is for R3C1 and R4C1.
Can we include a logical test in the formula which returns the value 92 for R3C1 and 44 for R4C1 if the formula cannot find "("?
I suggest you try =IF(ISNUMBER(Sheet1!A1),Sheet1!A1,"")
Only after editing the question do I now realise requirement seems to be for what may be served by a combination of OP's formula and mine above:
=IF(ISNUMBER(Sheet1!A1),Sheet1!A1,LEFT(Sheet1!A1,SEARCH("(",Sheet1!A1)-1))
This will returns text as before of 0 and 2 and numbers of 92 and 44.
yes, you can check for an error using ISERROR function:
=IF(ISERROR(LEFT(Sheet1!A1,SEARCH("(",Sheet1!A1)-1)),LEFT(Sheet1!A1,SEARCH("(",Sheet1!A1)-1))
so that is like an IF, THEN, ELSE block
IF LEFT(Sheet1!A1,SEARCH("(",Sheet1!A1)-1))= #VALUE
Then just take Sheet1!A1)-1
else take LEFT(Sheet1!A1,SEARCH("(",Sheet1!A1)-1)
that should get you started anyway
HTH
Philip

Excel: check all columns have a different value

I would like to know how to compare for every row that their (numeric) columns have different values or all of them are equal, and get the result (either a boolean or a 0/1) in another column. Something like:
colA colB colC Result
row1 12 12 45 false
row2 67 67 67 true
How could I write this formula concisely in Microsoft Excel? Note that the number of columns may vary and at least I have about 30 columns, so I don't want to name the columns in the formula, but write something like a for
Thank you.
If you want to test only numbers, what about?
=MIN(B1:B30)=MAX(B1:B30)
(if your range goes from 1 to 30)
for doesn't exist in Excel formula, the best way to deal with a for loop would be to use array formulas but this is not appropriated here.
what you may look for is a dynamic range but i can't see a way to implement it easily in your case
[EDIT] new formula thanks to Excelll's comment
=AND(MIN(B1:B30)=MAX(B1:B30),COUNTBLANK(B1:B30)=0)
If blank cells within a row are not an issue, #JMax offers a clever solution. However, if you want a blank cell to return "FALSE", you can use the following array formula:
=AND(EXACT(A1,B1:C1))
Enter this as an array formula by pressing Ctrl+Shift+Enter.

Resources