I have .setFormula() and stuck on this. I think the problem is the comma (&","). I have researched several online forum before posting this question but no luck; perhaps someone here could help me out. I do know the rules about using the "" and '' that's why I have tried several formulas but still, I receive the error message:
"Missing ) after argument list".
Your time and help is appreciated!
Original formula:
=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>"")&", "))
code:
me.getRange('B8').setFormula("=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>"") & ", "))");
Formulas I have tried but failed:
"=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>'') & ', '))");
'=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>'') & ', '))');
"=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>'') & ", "))");
'=arrayformula(concatenate(filter("Sheet1"!E2:E,"Sheet1"!E2:E<>"") & ", "))');
You dont need single quotes ' around Sheet1.
Try
me.getRange('B8')
.setFormula('=arrayformula(concatenate(filter(Sheet1!E2:E,Sheet1!E2:E<>"") & ", "))"');
If you still need it, you need to escape it with backlashes like this \':
me.getRange('B8')
.setFormula('=arrayformula(concatenate(filter(\'Sheet1\'!E2:E,\'Sheet1\'!E2:E<>"") & ", "))"');
Reference:
String § Escape notation
Related
Owner: IIf(isNull([Company]),[OwnerFirst] & ", " [OwnerLast],[Company])
You may have entered an invalid identifier or typed parenthesis following the Null constant
You need another ampersand operator before [OwnerLast]. Try-
=IIF(IsNull([Company]),[OwnerFirst] & ", " & [OwnerLast],[Company])
I've been looking for a solution to my problem, I'm close but not there yet.
I'm sure the key is a clever use of TRANSPOSE, QUERY, JOIN and/or SPLIT ( I think ... ) , but I'm no Google Sheet expert so I figured I asked you for help :)
Bellow are the images to better match my scenario (string with spaces).
Here the result I'd like:
Is there a magic formula for this?
kaam,
Here is one way...
=ArrayFormula(SPLIT(TRANSPOSE(SPLIT(JOIN(" ", QUERY(IF(A2:B<>"",A1:B1&"_"&A2:B,),,ROWS(A2:A))), " ")), "_"))
EDIT: If the values have spaces, try
=ArrayFormula(SUBSTITUTE(SPLIT(TRANSPOSE(SPLIT(JOIN(" ", QUERY(IF(A2:B<>"",A1:B1&"_"&SUBSTITUTE(A2:B, " ", "&"),),,ROWS(A2:A))), " ")), "_"), "&"," "))
After many trial and errors run, I cannot seem to fix the syntax error. I am trying to concatenate some data and have been using Allen Browne (where you can find the code for ConcatRelated) and I got the SQL from another stackoverflow question but they had different data types.
The following is the SQL for the query that I am trying to run, which is surprisingly producing the correct results as well as this error which makes the query useless. (StmntNd is Text field and Assmt_Group is a Number field)
SELECT sub.[StmntNd], sub.[Assmt_Group], sub.[StmntDes], ConcatRelated("Num_Code", "tbl_Property", "[StmntNd] = '" & sub.[StmntNd] & "' AND [Assmt_Group] = " & sub.[Assmt_Group], "num_Code") AS concat_num_code
FROM (SELECT q.[StmntNd], q.[Assmt_Group], q.[StmntDes] FROM tbl_Property AS q GROUP BY q.[StmntNd], q.[Assmt_Group], q.[StmntDes]) AS sub
ORDER BY sub.StmntNd, sub.Assmt_Group;
This is the error that I am currently receiving:
Thank you very much for any help. No matter what combination of quotes and apostrophes I use, I seem to keep getting an error.
try this
SELECT sub.[StmntNd], sub.[Assmt_Group], sub.[StmntDes], ConcatRelated("Num_Code", "tbl_Property", "[StmntNd] = '" & sub.[StmntNd] & "' AND [Assmt_Group] = " & sub.[Assmt_Group], "num_Code") AS concat_num_code
FROM (SELECT q.[StmntNd], q.[Assmt_Group], q.[StmntDes] FROM tbl_Property AS q
GROUP BY q.[StmntNd], q.[Assmt_Group], q.[StmntDes]) AS sub
Where q.[StmntNd] is Not Null
ORDER BY sub.StmntNd, sub.Assmt_Group;
Add where clause to the Column, I assumed column as q.[StmntNd]
I am trying to concatenate a number with a symbol in an MS Access textbox.
The field is a number (ie 44), and a symbol (ie °).
I have tried several different ways:
=[myNumber] & " °"
gives a #Type error
=myNumber & " °"
also results in a #Type error
=[myNumber] & [°]
results in a #Name error
=[myNumber] & " °"
works for me in Access 2010.
You can try to explicitely convert it into a string (and check for NULL, because CStr() doesn't like NULL):
=CStr(Nz([myNumber], "")) & " °"
I have an optional field in a database that I'm pulling out using a DAO Record Set. I need to check whether or not the field is set before I concatenate it with other fields. So far I have the following code snippet which I've tried with both Is and = (that's the obviously wrong syntax [[Is | =]]) to no avail. It appears that if I use = it will not correctly compare with Null and if I use Is then it complains that it's not comparing with an Object.
While Not rs.EOF
If rs.Fields("MiddleInitial") [[Is | =]] Null Then thisMiddleInitial = "" Else thisMiddleInitial = rs.Fields("MiddleInitial")
If prettyName(myLastName, myFirstName, myMiddleInitial) = prettyName(rs.Fields("LastName"), rs.Fields("FirstName"), thisMiddleInitial) Then
MsgBox "Yay!"
End If
rs.MoveNext
Wend
If there's a simpler way to do this I'm totally open to it. prettyName takes 3 Strings as parameters and initially I was just trying to pass rs.Fields("MiddleName") directly but it threw up at a Null value. I'd prefer to do something more direct like that but this is the best I could come up with.
How about:
IsNull(rs.Fields("MiddleInitial").Value)
You could also have a look at this article which has some explanation about Null values in Access VBA apps and how to handle them.
For the example you show, Nz would work:
thisMiddleInitial = Nz(rs!MiddleInitial,"")
Or simply concatenating the string with an empty string:
thisMiddleInitial = rs!MiddleInitial & ""
Your question has been answered by Remou, seems to me, but it occurs to me that you may just be trying to get proper concatenation of the name fields. In that case, you could use Mid() and Null propagation in VBA to get the result.
I don't use separate middle initial fields, so my usual name concatenation formula is:
Mid(("12" + LastName) & (", " + FirstName), 3)
The "12" string at the beginning is going to be tossed away if LastName is Not Null and ignored if it is null, because the + concatenation operator propagates Nulls.
To extend this to include middle intials would look like this:
Mid(("12" + LastName) & (", " + FirstName) & (" " + MiddleInitial), 3)
Assuming your UDF is not doing some kind of complicated cleanup of nicknames/abbreviations/etc., this could replace it entirely, seems to me.
If rst.Fields("MiddleInitial").Value = "Null" Then
This works for me. I use MS SQL Database.
I think the NoMatch option might work in this situation:
If rs.NoMatch = True Then
I prefer using the below to account for both Null and Empty string values. It's a good check to use you have forms collecting values from users.
If Trim(rs.Fields("MiddleInitial") & "") = "" then