Excel Formula IF statement - excel

I would really appreciate if you can help me on the excel formula logic. I am able to get the first part where I am able to display "1" in the check column if there is "Yes" in A,B,C columns and no values in either Amount 1, Amount 2 or Amount 3 columns (screenshot attached)
I also want to display "1" if there in "No" is A,B,C columns and a value in either Amount1, Amount2 or Amount 3 columns.
=IF(AND(E3="",F3="",G3="",OR(B3="Yes",C3="Yes",D3="Yes")),1,0)
How to add the below formula to above one
or IF(AND(E3<>"",F3<>"",G3<>"",OR(B3="No",C3="No",D3="No")),1,0)

=IF(OR(AND(E3= "",F3= "",G3= "",OR(B3="Yes",C3="Yes",D3="Yes")),
AND(E3<>"",F3<>"",G3<>"",OR(B3="No" ,C3="No" ,D3="No" ))),1,0)

Related

How can you in Excel total predefined values depending on cell values

I have a spreadsheet with two tabs. The first one contains Vehicle Types and a numeric score value.
Second Tab has like a variety of these vehicle types and what should be the total score. Depending on the vehicle types present in the respective neighbour cell.
See images below for illustration.
Is there a way via formula to get the total, in Column B in sheet 2, of the corresponding numeric values of column a from sheet 1?
For example, as per the illustration B2 in sheet would total 3; whereby in sheet 1 bus has a score of 1 and car 2.
Update:
As per the answer below, I have used the formula;
=SUMPRODUCT(ISNUMBER(FIND(" "&sheet1!A$2:A$4&" "," "&SUBSTITUTE(A4,CHAR(10)," ")&" "))*sheet1!B$2:B$4)
However, I am unfortunately getting zero as the value. Changing the line breaks in column A in sheet2 I am duly able to get the total. Is there a way to do it so irrespective of how the list is presented in the column the total will work?
I think you are after something like this:
Formula in E2:
=SUMPRODUCT(VLOOKUP(FILTERXML("<t><s>"&SUBSTITUTE(D2,CHAR(10),"</s><s>")&"</s></t>","//s"),A$2:B$4,2,FALSE))
If one has O365 you could just use SUM instead since it would auto-CSE the formula.
If you don't have Excel 2013 or later, you could try the following as another option (shorter but not my favourite):
=SUMPRODUCT(ISNUMBER(FIND(" "&A$2:A$4&" "," "&SUBSTITUTE(D2,CHAR(10)," ")&" "))*B$2:B$4)

Excel formula if with or returns wrong value

Got this formula:
=IF(OR(CP67>1,CZ67>1,DI67>1,DR67>1),2,"")
It should return "2" if value larger than 1 is present in one of the 4 columns, but it return value "2" in all of my 300 rows.There are formulas behind all 4 columns in hand, but (displayed) values in columns are either a blank cell or a number ranging from 1 to 3. Whole sheet is formatted as "Standard" (and table), and all values is placed to the right in the cell (not text).
This should be a no-brainer, but I'm lost. Anyone that can spot what's wrong? If I do a test of this in a colmplete blank wb/sh it works just fine!
Press F9, sounds like you have manual calculation on.

EXCEL - SUM column if date matches TODAY()

I've tried using SUMIF to obtain my results but it doesn't work properly.
I have a row of dates (XX/XX/XXXX format) and I would like to check this row for the current date.
If the row contains the current date, then I would like to sum the total of that column and row 5-20.
For example - today is 10/13/2016. I would like to search for TODAY() in a certain row (Row 1 for example), and if TODAY() is found, then total this column from row 1 down to row 3.
--A-- --B--
10/13/2016 10/14/16
1 50 10
2 10 4
3 5 6
The result should be 65 only IF the date matches TODAY().
I've also checked on giving the column letter based on the date but with no luck.
Any tips are appeciated! Thank you.
I think you can achieve this with a simple IF and a SUM
i.e. in your example above if you want the result to appear on the bottom row you can just use:
=if(B2=today(), sum(B3:B5), "")
This will display the sum at the bottom of the column for columns where the date = today and a blank in the other columns
You need to use the OFFSET function. You can find the documentation here: https://support.office.com/en-us/article/OFFSET-function-C8DE19AE-DD79-4B9B-A14E-B4D906D11B66
In your particular example the following formula will work:
=SUM(OFFSET(D2, 1, MATCH(B2, $D$2:$F$2, FALSE) - 1, 20))
You can see the formula working below. Assuming you know what the SUM formula is doing, I will explain what the OFFSET formula is doing:
First Parameter: Says start at cell D2
Second Parameter: This is how many row up/down do you want to do. In your case you need start at row below the date so '1' it is.
Third Parameter: This is how many columns to the right do you want to
go. Well the number of columns you want to go is based upon where
your date is. So this uses the match formula to figure out how far
to the right to go.
Fourth Parameter: This is how many row do you want to include. I just picked 20 to include the 20 rows below the selected cell.
You obviously need to modify the parameters a little bit to fit your exact data shape.
So I'll give it a shot:
{=SUM(HLOOKUP(TODAY(),Table_With_Dates_and_Three_Rows_Cell_Reference,{2,3,4}))}
NB: Don't type {} but put the formula inside it and then hit Ctrl+Shift+Enter to create what is called an array formula (it does array calculations element by element then submits the aggregating function value---in this case that is sum).

How to find a specific text from a column that a set of comma separated values in Excel?

I have a column like this
Now I know the set of values. Like someone was asked about 'Sports' and he/she had the below choices:
Cricket
Tennis
Football
Others
Now the values that you see in any cell of the column apart from 'Cricket', 'Tennis' or 'Football' are entered as 'Others'
So I want the output in this manner that will only fetch what has been put as 'Others' and where it was not chosen it will be '0' (zero)
But if you see I was taking about 'Others' as an example. For this example, there is no such letter as 'Others', instead of there are 'I dont like any sports' or 'Playing sports was good at home' etc which can be anything followed by. So I want to show anything that doesn't match with 'Cricket', 'Football' or 'Tennis'
I'm a very novice at Excel and kind of doing this first time. Can anyone help what formula should I write at the starting of B column?
Enter this as a function in the first row in your B column and pull it down for all your rows:
=IF(A1="Others";A1;0)
If you pull it down correctly, then the row below it should read =IF(A2="Others";A2;0), rinse and repeat for all rows below. All cells in the B column should now either show "Others" or 0.
This is a simple IF statement in Excel and should be read as:
=IF(A1="Others";A1;0)
Or in pseudo-code:
IF A1 EQUALS "Others" THEN B1 EQUALS A1 ELSE B1 EQUALS 0
You can also replace the A1 and 0 in your formula by anything you like, e.g. you can set it to true and false by changing it to =IF(A1="Others";true;false).
I don't know what you are planning to use it for, but you can also just set a filter at the top row, and filter out every cell which does not contain "Others". When working with large Excel-files, filters are your friend.

Find cells referring to blank cells

What is the best way to find cells whose formulas refer to blank cells in Excel VBA. I'd like to delete any cell that references a blank cell.
More concretely, I have a two sheets: One sheet contains the actual values:
Product Month1 Month2 Month3
Sample1 1 3 5
Sample2 5 7 6
Sample3 3 8 2
The other is a summary view, with formulas to sum up the values, with the following formulas:
Product Month1
=values!A2 =SUM(values!B2:D2)
=values!A3 =SUM(values!B3:D3)
=values!A4 =SUM(values!B4:D4)
=values!A5 =SUM(values!B5:D5)
TOTAL =SUM(values!B:D)
Now in the previous example, the last raw refers to a blank row, namely the fifth row. Excel will show those cells as "0". Is there a mechanism to delete those cells within VBA?
Please note I prefer deleting the rows, to keep the TOTAL row close to the actual last value. Otherwise, the Total row might be distant from the rest of the values. Also, having blank cells with formulas may lead to a large Excel file.
EDIT: Clarified the question to role out the keeping the cells blank.
Is it always the last row, that could evaluate to 0?
If so u Could use a IF statement like:
=IF(SUM(values!B2:D2) > 0 ,values!A2,"") =IF(SUM(values!B2:D2),SUM(values!B2:D2),"")
No VBA needed...
I think Autofilter is the way to go here. If there's a zero in column A, I'm guessing you want to hide that whole row. You say delete, but I wonder if hide is a better way.
Put a filter on the range and for column A select everything except 0.
You could do this without having to write code to delete rows. I would use a variant of Arnoldiuss' solution.
For the Month total use:
=IF(LEN(values!A2)>0,SUM(B2:D2),"")
In this way, you can simply fill-down all the formulas and not have to worry if you reference a non-existent product.
Based on your edit i guess a pivot table fits your needs.
Add the products to the rowlabels and add the following calculated field to the values
=SUM(Month1,Month2,Month3)
Then add a value filter > 0
I would not recommend deleting rows in the "formula worksheet", for future use the series would wrecked, because of the missing references.

Resources