If cell is blank, what to do? - excel
I have line of code in excel and would like to add a function that If reference cell is empty, just return me empty. How am I able to add to that? Thanks in advance!
Here My code is so far:
=IF(
ISNA(VLOOKUP($A2,'[DataSheet.xlsx]SOC 41'!$C$2:$P$5000,1,FALSE))=TRUE,"","R41: " & VLOOKUP($A2,'[DataSheet.xlsx]SOC 41'!$C$2:$P$5000,10,FALSE))&"
"&IF(ISNA(VLOOKUP($A2,'[DataSheet.xlsx]SOC 42'!$C$2:$P$5000,1,FALSE))=TRUE,"","R42: " & VLOOKUP($A2,'[DataSheet.xlsx]SOC 42'!$C$2:$P$5000,10,FALSE))&"
"&IF(ISNA(VLOOKUP($A2,'[DataSheet.xlsx]SOC 43'!$C$2:$P$5000,1,FALSE))=TRUE,"","R43: " & VLOOKUP($A2,'[DataSheet.xlsx]SOC 43'!$C$2:$P$5000,10,FALSE))
Again, what if return cell got an empty string, how to add ISBLANK (or something else) in to the code?
Even I tried this and didn't work.
=IF(OR(
VLOOKUP($A11,'[DataSheet]SOC 41'!$C$2:$P$5000,11,FALSE)="",
VLOOKUP($A11,'[DataSheet]SOC 42'!$C$2:$P$5000,11,FALSE)="",
VLOOKUP($A11,'[DataSheet]SOC 43'!$C$2:$P$5000,11,FALSE)=""),"",
IF(
ISNA(VLOOKUP($A11,'[DataSheet]SOC 41'!$C$2:$P$5000,1,FALSE))=TRUE,"","R41: " & VLOOKUP($A11,'[DataSheet]SOC 41'!$C$2:$P$5000,11,FALSE))&"
"&IF(ISNA(VLOOKUP($A11,'[DataSheet]SOC 42'!$C$2:$P$5000,1,FALSE))=TRUE,"","R42: " & VLOOKUP($A11,'[DataSheet]SOC 42'!$C$2:$P$5000,11,FALSE))&"
"&IF(ISNA(VLOOKUP($A11,'[DataSheet]SOC 43'!$C$2:$P$5000,1,FALSE))=TRUE,"","R43: " & VLOOKUP($A11,'[DataSheet]SOC 43'!$C$2:$P$5000,11,FALSE)))
Please help!
Nest the formula in:
=if(A2<>"",formula,"")
Related
How do you look for a condition in a range and then get info from another range into a single cell?
So at the moment I have a working code to get multiple items in a cell following a condition My code is: =Contatenate( IF('Sheet1'!E3 = "R",'sheet1'!A3,""), " ", IF('Sheet1'!E4 = "R",'sheet1'!A4,""), " ", and so on..... it then returns every name that meets this condition. I was just wondering if there was a quicker way to do this. Thanks!
Leaving the solution as an answer to make it more clear: =ArrayFormula(TEXTJOIN(" ",TRUE,IF('Contact & Overview'!E103:E122="R",'Contact & Overview'!A103:A122,""))) From Sheets TEXTJOIN: Sample Usage TEXTJOIN(“ “, TRUE, “hello”, “world”) TEXTJOIN(“, ”, FALSE, A1:A5) Syntax TEXTJOIN(delimiter, ignore_empty, text1, [text2, ...])
Expression.Error when dynamically passing in Teradata SQL query (with column aliases) to ODBC query
I have a macro that prompts me for a SQL query (unless it was called by another Sub, in which case it uses the argument that was passed into its optional string parameter as the query) and then executes the query against my Teradata SQL database. It works fine, unless there's a column alias containing a space in the query. Example query: SELECT 2 + 2 AS "Query Result"; Error: Run-time error '1004': [Expression.Error] The name 'Source' wasn't recognized. Make sure it's spelled correctly. The line of code which I believe is the culprit is as follows (my apologies for the readability-- I recorded the macro, modified it just enough to get it to work somewhat dynamically and then haven't touched it since). ActiveWorkbook.Queries.Add Name:=queryName, formula:= _ "let" & Chr(13) & "" & Chr(10) & " Source = Odbc.Query(""dsn=my-server-name"", " & Chr(34) & code & Chr(34) & ")" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " Source" I assume it has to do with the fact that the example query above has double quotes for the alias, which are confusing the syntax when trying to be interpolated. Any help would be greatly appreciated!
Here's what the string for the formula is set to in this line: ActiveWorkbook.Queries.Add Name:=queryName, formula:=<string here> after all the chr() and concatenation are done: let Source = Odbc.Query("dsn=my-server-name", "<code>") in Source That token <code> is replaced by whatever is in your variable code. So I suspect you are correct in that this formula would need to have it's double quotes escaped fully. In other words this string you are building form Formula is going to be evaluated as code itself, and even in that evaluation it will be passing more code (your SQL) onto the Teradata server to be evaluated there. You are in code inception. VBA code writing powerquery code writing Teradata code. Understanding that and guessing a bit here, I'm thinking your current code variable looks something like: code="SELECT 2 + 2 AS ""Query Result"";" Your double quotes are already escaped for VBA. BUT because you have to survive another round of eval in powerquery you need to escape once again. Instead: code="SELECT 2 + 2 AS """"Query Result"""";" *I think...
I want to check a IF formula by using the IFS function
I have the following IF function, which tells us the source of some data in Excel. =IF(D168=T168, " ", IF(AND(S168=0, R168<>0), "Invalid number", IF(AND(R168=0, Q168<>0),"Invalid Text", IF(AND(D168=0, T168<>0), "Source X", IF(AND(T168<>0, T168<>F168, OR (T168=G168, T168=O168, T168=P168)), "Source Y", " "))))) Now I want to check that this formula is pulling the right source with an IFS function. I have tried IFS(D168=T168, " ", S168=0 R168<>0, "Invalid Number") but this formula returns an error. I want to basically translate the IF formula above into an IFS formula.
The syntax for the IFS function in Microsoft Excel is: =IFS( condition1, return1 [,condition2, return2] ... [,condition127, return127] ) So after S=168, what value? And don't forget the commas! You probably omitted the AND. Because that is your 'condition 2'. i.e. something that will return a boolean true or false result. AND(S168=0, R168<>0) Leading to: =IFS(D168=T168, " ", AND(S168=0, R168<>0), "Invalid Number") etc, etc. Let me know if that works for you.
Excel Amount in Words Formula
I found this formula below to convert amounts to words for google spreadsheets and it works perfectly. But now I want to use it in excel 2010 and I get a lot of errors. I also cannot use VBA. Thanks for any help. =if(or(isBlank(A1),not(isNumber(A1)),A1>=power(10,15)),ifError(1/0,"Error"),trim(arrayFormula(concatenate(if(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))<100,"",choose(int(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))/100)," One"," Two"," Three"," Four"," Five"," Six"," Seven"," Eight"," Nine") & " Hundred") & if(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)<>0,if(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))>100," And",if(A1>power(10,{15,12,9,6,3}),choose({1,2,3,4,5},"","","",""," And"),"")),"") & if(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)=0,"",if(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)<20,choose(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)," One"," Two"," Three"," Four"," Five"," Six"," Seven"," Eight"," Nine"," Ten"," Eleven"," Twelve"," Thirteen"," Fourteen"," Fifteen"," Sixteen"," Seventeen"," Eighteen"," Nineteen"),choose(int(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)/10),""," Twenty"," Thirty"," Forty"," Fifty"," Sixty"," Seventy"," Eighty"," Ninety") & if(mod(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100),10)=0,"","-" & choose(mod(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100),10),"One","Two","Three","Four","Five","Six","Seven","Eight","Nine")))) & if(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))=0,"",choose({1,2,3,4,5}," Trillion"," Billion"," Million"," Thousand","")))) & if(A1>=2," Rand",if(A1>=1," Rand","")) & if((round(A1-trunc(A1),2)*100=0)+(A1<1),""," And") & if(round(A1-trunc(A1),2)*100=0,"",if(round(A1-trunc(A1),2)*100=1," One Cent",if(round(A1-trunc(A1),2)*100<20,choose(round(A1-trunc(A1),2)*100," One"," Two"," Three"," Four"," Five"," Six"," Seven"," Eight"," Nine"," Ten"," Eleven"," Twelve"," Thirteen"," Fourteen"," Fifteen"," Sixteen"," Seventeen"," Eighteen"," Nineteen"),choose(int(round(A1-trunc(A1),2)*100/10),""," Twenty"," Thirty"," Forty"," Fifty"," Sixty"," Seventy"," Eighty"," Ninety") & if(mod(round(A1-trunc(A1),2)*100,10)=0,"","-" & choose(mod(round(A1-trunc(A1),2)*100,10),"One","Two","Three","Four","Five","Six","Seven","Eight","Nine"))) & " Cent"))))
If your numbers do not need to go above ~100, it may be easier to make two columns, the first with the 1,2,3 etc. and the second with one,two,three etc. Then you can do VLOOKUP() on that table. An example can be found here: https://www.dropbox.com/s/e44dnkg3he8b8il/NumericalToAlpha.xlsx
how do I format currency inside the expression of Excel cell?
I am trying to figure out how to format the result in an expression in Excel. I wrote =IF(C30 > B30, "You would save $" & Format(C30-B30, "Currency") & "!", "No savings") inside the cell but it doesn't work. Simply put, I want the currency formatted inside the expression. How?
Have you tried the Text function? =IF(C30 > B30, "You would save " & Text(C30-B30, "$0.00") & "!", "No savings")
Use this formula =IF(C30 > B30, "You would save " & Currency(C30-B30, 0) & "!", "No savings")
Many years later, this works, too! =IF(C4>D4,"You would save " & DOLLAR(C4-D4,2) & "!","No Savings!")
I think you are looking for the Concatenate function. Excel doesn't seem to have the Format function you have indicated. This worked for me in Excel 2007: =IF(C30 > B30, CONCATENATE("You would save $",C30-B30, "!"), "No savings")