Excel IF multiple columns - excel

Im working with a large excel questionnaire that i would like to simplify the data output for further evaluation.
What I'm trying to make is an IF statement, so that if the X is in fueloil the P coloum will write Fueloil ect..
=IF(K2="X";K1)
However when I'm trying to add another IF statement excel returns VALUE. is IF the right way to go about this or is there another way of doing this?

You don't need IF for this at all. You can use an Index/Match combo formula as demonstrated in the screenshot below. The formula in cell P2 is copied down.
=INDEX($K$1:$O$1,MATCH("x",K2:O2,0))
In words: Find the "x" in the current row and return the value from row 1 of that column.
If your regional settings require semicolons to separate parameters in formulas, please use
=INDEX($K$1:$O$1;MATCH("x";K2:O2;0))

Related

Error in conditional formatting formula where the same formula works in a cell

I'm trying to conditionally format a column of cells based on whether the combination of two other columns appear in a Table.
Here is a link to the test workbook I am playing with and screenshots below for those that don't like clicking strangers links!
https://1drv.ms/x/s!Al1Kq21dFT1ij4ktFd0mzBniNX00tQ?e=L6aQm4
On the far left is an Excel table ([Table1]) that contains a list of valid combinations of [Category] and [Item]
Columns E&F contain some sample data to test against
Column G is the number of matching combinations I expect to return from a COUNTIFS() function
Column H is simply the same formula compared to 0 so I get a boolean result.
The actual formula to get the result shown in Column H is
=COUNTIFS(Table1[Category],"="&E4, Table1[Item],"="&F4)=0
All the above works as expected.
In Column J is just some literal text with conditional formatting. The condition is simply =H4, again this works as expected.
Now to the problem...
I want to avoid having the helper column (H) so I thought I could just use the same formula that I used in column H, as my condition formula.
So, I tried to use this in the conditional formatting formula dialog.
=COUNTIFS(Table1[Category],"="&E4, Table1[Item],"="&F4)=0
and with parantheses
=(COUNTIFS(Table1[Category],"="&E4, Table1[Item],"="&F4)=0)
Unfortunately, this results in the generic "There's a problem with this formula" error message.
If might be that there are some limitations with conditional formatting formulae that I'm not aware of (I'm no Excel guru, I'm a SQL developer really).
BTW: I need to stick with using a table as my real-world scenario is that there will be several tables, all populated from a database via a separate process with lengths varying from 2 or 3 entries to potentially thousands.
I would appreciate any help, even if it's just to say "You can't do this, you'll need to use your helper column..."
Thanks for looking...

Excel formula checklist in employees

I want to know about this Excel formula and how it works
IFERROR(COUNTIF(OFFSET(T_E[[#Headers],[EMPLOYEE NAME]],MATCH(I_E,L_E,0),MATCH("ACT 1 DT",L_H,0)-1,1,N_S),">0")&" / "&N_S,"")
Please tell me about this formula and how can I change this by adding or removing.
The best for trying how function works is to try it in excel, but still...
You want to know what the whole function works or just how partial functions work?
In general, the function addresses to formatted table and to named parts of the table, so it should return value from formatted table, that is x rows from employee name in row and x columns from employee name in this row.
How many depends on what is under "I_E", "L_E" and "L_H" and "N_S", I cannot tell without this knowledge.
How to evaluate a formula
If you would like to better understand how a complex formula works, use the Formula Evaluator in Excel. Therefore select the cell that contains the formula, and on the Formulas tab, in the Formula Auditing group, click Evaluate Formula.
Also there is a documentation for all formula functions. With this and the Formula Evaluator you should be able to trace what the formula does.

Excel: Using ISBLANK in conjunction with IF statement

I am trying to develop a simple expiration date with conditional highlighting. I've set up the column I to an IF statement based on a logic test in column G, drawing value from Column A. Formula is currently:
=IF(G2="N", A2+7,A2+60)
Problem is, I'm making this for a complete excel newbie so I need it foolproof. I want column I to remain blank as long as either cells in the corresponding column A or G are blank (not relevant which, they'll both be filled together). I've tried a few nested and "AND" statements to no avail.
You need to use OR to test if either A2 or G2 is blank using the ISBLANK function:
=IF(OR(ISBLANK(A2),ISBLANK(G2)),"",IF(G2="N",A2+7,A2+60))
If so, you can return "" if either input is blank, and if both are populated then go ahead and use your original formula.
One option is to use COUNTA function to determine how many cells are populated and only use the IF function if the result is 2, e.g.
=IF(COUNTA(A2,G2)=2,IF(G2="N",A2+7,A2+60),"")

Excel 2010 showing items in drop down list where criteria is met

I'm going around in circles with this and have tried as many different options as I can think of - VLOOKUP, INDEX/MATCH, IF etc... but I'm failing everytime.
I need to create a drop down list in sheet 3 (column A) that gets populated with values in column B of sheet 2, only where the value in column G of sheet 2 is "Yes". The values in sheet 2 look as follows:
This is what is shown at present:
I am using the following formula within Name Manager to get to this point:
=OFFSET(Units!$B$11,0,0,COUNTIF(Units!$B$11:$B$202,">"""),1)
and although this works, it's not quite as I need it to be. I've tried using Index/Match, small, VLOOKUP etc... but Excel reports that either I've too few arguments or can't reference a worksheet.
I've literally been though as many excel websites as I can find but no one seems to cover creating drop down lists where the drop down is dependent on a specific selection.
The values within sheet 2, column B are obtained from a hidden sheet and collected using the following query:
=IF(ISERROR(INDEX(All_Units!$D$2:$D$660542,MATCH(Units!A11,All_Units!$C$2:$C$660540,0))),"",INDEX(All_Units!$D$2:$D$660542,MATCH(Units!A11,All_Units!$C$2:$C$660540,0)))
I wondered whether I could take this query and use it to generate the drop down list, something along the lines of:
=INDEX(Units!$B$11:$B$202,MATCH(Units!$G$11:$G$202="Yes",Units!$G$11:$G$202,0)))
but this returns an error. The closest I got was using the OFFSET formula above but performing a COUNTIF, however; this unsurprisingly wouldn't tie Column B to the corresponding 'Yes' in column G.
Does anyone have any ideas as to how I can get this working?
You will need to create another sheet into which you will place an array formula. This formula will return all the desired output.
so create a sheet and name it something like DataVal
In A2 put the following array formula:
=IFERROR(INDEX(Units!$B$11:$B$202,MATCH(1,(Units!$G$11:$G$202="Yes")*(COUNTIF($A$1:A1,Units!$B$11:$B$202)=0),0)),"")
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter. If done correctly then Excel will put {} around the formula.
Then copy/drag down far enough to ensure capturing every possible return.
Then use another INDEX/MATCH to create the named range (OFFSET() is volatile and should be avoided when possible). The formula would be something like:
=DataVal!$A$2:INDEX(DataVal!$A:$A,MATCH("ZZZ",DataVal$A:$A))
This will dynamically set the named range to the extent of the dynamic list created by the array formula above.

Using nesting vlookup formulas for use in automation code

I am trying to write a formula that uses different vlookups depending on whether the formulas produce errors or not. I have 3 tabs, each with 3 columns.the first two columns contain values that are in the vlookup, with the third colum containing the value I want to find. Basically i want a formula that will use different vlookups depending on whether the lookup value is found in teh first tab or the second . Below is the formula i am working with. It works to bring in values from Sheet1 into Sheet3, but doesnt work when the values are in Sheet2. Also will be inserting this formula into vba code for automation use.
=IF(OR(ISERROR(VLOOKUP(B2,Sheet1!B2:C19,2,FALSE)),ISBLANK(VLOOKUP(Sheet3!B2,Sheet1!B1:C19,2,FALSE))),IF(OR(ISERROR(VLOOKUP(Sheet3!A2,Sheet1!A1:C19,3,FALSE)),ISBLANK(VLOOKUP(Sheet3!A2,Sheet1!A1:C19,3,FALSE))),IF(OR(ISERROR(VLOOKUP(Sheet3!B2,Sheet2!B1:C21,2,FALSE)),ISBLANK(VLOOKUP(Sheet3!B2,Sheet2!B1:C21,2,FALSE))),IF(OR((ISERROR(VLOOKUP(Sheet3!A2,Sheet2!A1:C21,3,FALSE))),ISBLANK(VLOOKUP(Sheet3!A2,Sheet2!A1:C21,3,FALSE))),"non",VLOOKUP(Sheet3!A2,Sheet2!A1:C21,3,FALSE)),VLOOKUP(Sheet3!B2,Sheet2!B1:C21,2,FALSE)),VLOOKUP(Sheet3!A2,Sheet1!A1:C19,3,FALSE)),VLOOKUP(Sheet3!B2,Sheet1!B1:C19,2,FALSE))
it returns the value sI am looking for up until the lookup values start occuring in Sheet2. At that point it shows me "non".
Any help would be greatly appreciated! Thanks
Your first VLOOKUP does not reference "Sheet3".
I think The below equation does what you are looking to do (assumes you are on Sheet3).
=IF(IFERROR(VLOOKUP($B$1,Sheet1!A:C,3,FALSE),"")="",IF(IFERROR(VLOOKUP($B$1,Sheet1!B:C,2,FALSE),"")="",IF(IFERROR(VLOOKUP($B$2,Sheet2!B:C,2,FALSE),"")="",IF(IFERROR(VLOOKUP($B$2,Sheet2!A:C,3,FALSE),"")="","nan",VLOOKUP($B$2,Sheet2!A:C,3,FALSE)),VLOOKUP($B$2,Sheet2!B:C,2,FALSE)),VLOOKUP($B$1,Sheet1!B:C,2,FALSE)),VLOOKUP($B$1,Sheet1!A:C,3,FALSE))

Resources