I have a column in a sheet,
I want to change the value of the cell of another sheet with rules:
If the text is: "Won" or "Lost" or "Cancel" Then get these text values into the target cell.
Else values then get the value of right above the From cell.
My syntax like this:
=if('Weekly Plan'!F5 = "Won" or 'Weekly Plan'!F5 = "Lost" or 'Weekly Plan'!F5 = "Cancel";'Weekly Plan'!F5;'Weekly Plan'!F4)
But it has given me the error:
Error
Formula parses error.
Invalid:
Input must fall within the specified range
I don't know how to fix this
Thanks!
Maybe something like that?
=IF(OR(F5="Won",F5="Lost",F5="Cancel"),F5,F4)
You seem not to understand the way logical operators work in Excel formulas:
It's not: A OR B OR C
But: OR(A;B;C)
Or (in case you might need and AND-operator):
It's not: A AND B AND C
But: AND(A;B;C)
Keep out: the semicolon can be replaced by a comma, this is determined by your locale.
Good luck
Related
I am trying to create a pricing spreadsheet for the company I work for.
I am looking for a formula that returns a value from a specific cell based on text in two other cells.
An example is:
Sheet1:A1="Clear", Sheet1:B1="Black"
Sheet2:A1="Opacity", A2="Clear", A3="Yellow"
Sheet2:B1="Color", B2="Brown", B3="Black"
Sheet2:C1="Price", C2:1, C3:4
Return
IF Sheet1:A1="Clear" AND Sheet1:B1="Black", RETURN specific value from Sheet2:C column
Any tips or references I can look at to get this figured out?
I think below will help you to reach to the desired answer.
Add a new A column in sheet 2 (Later you can hide this)
sheet2:A1 -> =CONCATENATE(B2,",",C2) Drag to the End of the table.
sheet1:D1 -> =CONCATENATE(A1,",",B1) (Later you can hide this)
sheet1:C1 -> =VLOOKUP(D1,Sheet2!$A:$D,4,0) (What you expected)
Have you tried simple vlookup with the values ? Something like:
Vlookup ((sheet1$colA & sheet1colB), sheet2$colC, 1,0)
Try this. Will test for more and update.
I'm having trouble figuring this out, I've inserted an IF statement into my code but my fields are still showing 0's where there are blanks in my table. Any help would be appreciated!
=IFERROR(INDEX('Error'!$A$2:$I$5000,SMALL(IF('Error'!$E$2:$E$5000="","",IF(OR('Error'!$E$2:$E$5000="does
not match",'Error'!$A$2:$I$5000="not on the
Route"),ROW('Error'!$A$2:$A$5000))),ROW(2:2))-1,1),"")
Edited to include expected results and table
If the purpose of your function is to determine if at least one cell in your range is empty, you can use the COUNTBLANK() function like this :
=IF(COUNTBLANK('Error'!$E$2:$E$5000) > 0, "at least one is empty", "no empty cell")
I needed to add the condition at the very beginning of the code to make this work, so there are now essentially two index/small conditions. Blank values now populate as expected.
{=IFERROR(IF(INDEX('Error Report'!$A$2:$I$5000,SMALL(IF(OR('Error Report'!$E$2:$E$5000="Dealer does not match the shipment",'Error Report'!$A$2:$I$5000="Dealer ID is not on the Route"),ROW('Error Report'!$A$2:$A$5000)),ROW(4:4))-1,1)="","",INDEX('Error Report'!$A$2:$I$5000,SMALL(IF(OR('Error Report'!$E$2:$E$5000="Dealer does not match the shipment",'Error Report'!$A$2:$I$5000="Dealer ID is not on the Route"),ROW('Error Report'!$A$2:$A$5000)),ROW(4:4))-1,1)),"")}
I have a situation where I am referencing cells in a different worksheet and returning the values of cells from that worksheet. Although it works, I find my current method inefficient because I have to repeat the formula in the logical test part of the IF statement:
=IF(**EXTREMELY LONG COMPLICATED FORMULA** <> "", **EXTREMELY LONG COMPLICATED FORMULA**, "")
As you can see, I must repeat the main part of the formula just to check if it is blank first. If I do not do this, I get a zero in the cell (for blank values in the referenced worksheet). I'm looking for something more like:
=IF(**EXTREMELY LONG COMPLICATED FORMULA** <> "", **RETURN VALUE**, "")
This looks cleaner to me because I won't have to repeat myself. Also, if we ever have to update the formula, I won't have to duplicate my changes to the repeated parts. Is there a way to do this?
The above is actually a simplified version of my problem, but the answer should get me where I need to go. My actual formula has nested IF statements checking along the way for blanks. For reference, here it is:
=IFERROR(IF(SMALL(IF(ImportedData!$H$2:$H$1000>=DataFilters!$A$1,IF(ImportedData!$G$2:$G$1000=DataFilters!$A$15,ROW(ImportedData!A$2:A$1000)-ROW(ImportedData!A$2)+1)),ROWS(ImportedData!A$2:ImportedData!A2))<>"",IF(INDEX(ImportedData!A$2:A$1000,SMALL(IF(ImportedData!$H$2:$H$1000>=DataFilters!$A$1,IF(ImportedData!$G$2:$G$1000=DataFilters!$A$15,ROW(ImportedData!A$2:A$1000)-ROW(ImportedData!A$2)+1)),ROWS(ImportedData!A$2:ImportedData!A2)))<>"",INDEX(ImportedData!A$2:A$1000,SMALL(IF(ImportedData!$H$2:$H$1000>=DataFilters!$A$1,IF(ImportedData!$G$2:$G$1000=DataFilters!$A$15,ROW(ImportedData!A$2:A$1000)-ROW(ImportedData!A$2)+1)),ROWS(ImportedData!A$2:ImportedData!A2))),""),""),"")
The most obvious solution is to use a helper column or cell. Just put EXTREMELY LONG COMPLICATED FORMULA somewhere in your spreadsheet, then refer to that cell in your IF formula.
Edit
To avoid a helper column, here is a trick I've used on occasion:
=IFERROR(VALUE(long_formula&""),"")
What this does is, concatenate the result of long formula with an empty string (which converts it to a string), then take the value of all that (which converts it back to a number if possible), then substitute any errors with a blank. (An error would occur if you attempt to take the value of something that's not numerical.)
This will only work if you either have a numerical result or an empty result. It will fail if you have a text result.
As of March 2020, Excel includes the LET function. You can write:
=LET(ELCF,**EXTREMELY LONG COMPLICATED FORMULA**,IF(ELCF <> "", ELCF, ""))
Where the three parameters are:
the name you will use to refer to your calculation,
the calculation itself, and
the final formula using the calculation.
The function also allows for multiple names to be defined. The general syntax is:
=LET(name1, name_value1, calculation_or_name2, [name_value2, calculation_or_name3...])
https://support.microsoft.com/en-us/office/let-function-34842dd8-b92b-4d3f-b325-b8b8f9908999
Do you need the blank in the cell for further calulations or if-functions or Do you just dont want to see the 0s?
Second case:
Just use a number format for the column like
0,00;-0,00;"";#
First case:
Put the following code in a module:
Option Explicit
Public Function IfEmpty(LongFormula As String) As String
If LongFormula = "" Then
IfEmpty = ""
Else
IfEmpty = LongFormula
End If
End Function
And use it in your worksheet like
=IfEmpty(**EXTREMELY LONG COMPLICATED FORMULA**)
I'd like to use something like the EVALUATE-Function in Excel for if-statements.
I've got the following issue: I'd like to use Excel to validate my data. I've got three sheets:
the real data I'd like to check. Each row represents a customer and each column some data. The columns have specific names like “age”, “name”, …
the description of the checks I’d like to perform. Each row represents one check and I’ve got 3 columns: 1 check_id – an identifier of each check; 2 check_desc – a description of the check that every normal person can understand like “Age below 18”; 3 rule – the Excel Formula as a string like If(age<18, “error”, “no error”)
the place where sheet 1 and 2 should come together. Each row should represent one customer and each column one check.
Now, if I’ve got for example check_1 “If(age<18, “error”, “no error”)” and the customer data 10 and 20, then the check for the first customer should fire and the check for the second shouldn’t.
If the data is changed, and the age is set from 10 to 18, then everything should be fine, or if the rule is changes to “If(age<21, “error”, “no error”)” then the new condition should be applied to all data.
Is something like this possible?
With the evaluate function only ‘simple’ formulas work.
Thanks in advance,
Martin
Attached you can find the
Excel-Sample File
You will definitely need some VBA here. Make a custom EVAL function:
Public Function EVAL(ByRef Rng As Range, Formula As String) As Variant
Dim RngAddress As String
RngAddress = "'" & Rng.Parent.Name & "'!" & Rng.Address(External:=False)
EVAL = Evaluate(Replace(Formula, "$", RngAddress))
End Function
Then you can easily evaluate your values with formulas passed as text ($ is for parameter):
=EVAL(A1, "IF($<21,""error"",""no error"")")
(note the escaped double quotes). But you would rather pass formula from another cell - then you can specify formula in cell with single quotes:
IF($<21,"error","no error")
=EVAL(A1, B1)
I personally would rename check_desc!B2 to "Check_1" (named range) and then refer to that. You can use the INDIRECT function as well once you've renamed your column header "Check_1" as well.
Note: the value in this case should be "18" instead of "age below 18". You can of course change the number format to "age below "0.
If the relations are changing too I would insert a table that would have uniform formulae changing in each cell when changed in one cell.
The only issue you would then face is the non-expanding nature of your table. You can use VBA for this, but maintaining formulae increases your accountability even if it would be slightly easier not to deal with nasty nested functions.
I am trying to validate an Excel column to have only values containing a value with length > 1 and ending with "d".
My attempt was the following formula:
=AND(LEN(INDIRECT(ADDRESS(ROW(),COLUMN())))>1,RIGHT(INDIRECT(ADDRESS(ROW(),COLUMN())),1) = "d")
Excel says that the formula contains errors.
The strange thing is that the first part itself works correct. But when i put it into an AND i get the error. Also when i replace the inderect reference with an absolut one it will work:
=LEN(INDIRECT(ADDRESS(ROW(),COLUMN())))>1 => works
=AND(LEN(F4)>1, TRUE) => works
=AND(LEN(INDIRECT(ADDRESS(ROW(),COLUMN())))>1, TRUE) => fails
Why is this? Is there another way or a workaround to do this?
Thanks in advance, Marco
Not sure why you need this to be so complicated. In data/validation Custom formula for the top cell in the column, put something like =AND(LEN(H1)>1,RIGHT(H1,1)="d") (for col H, for example). Then Copy that cell, and Paste Special/Validation for the rest of the cells in the column. Any good?