Concatenate in excel with special characters - excel

This is my excel table
state City Name area type
GUJARAT Abdasa City
GUJARAT Adalaj City
GUJARAT Ahwa City
I want to create this(in the row next to area type of course)
('GUJARAT','Abdasa','City'),
For that I have tried following formulas
=CONCATENATE("('"+A2+"','"+B2+"','"+C2+"'),")
=CONCATENATE("('" & A2 & "','" & B2 & "','" & C2 & "'),")
I don't know much about Excel is this possible?

You don't need to use both CONCATENATE() and & operator - they do the same thing.
If you use &, write:
="('" & A2 & "','" & B2 & "','" & C2 & "'),"
If CONCATENATE(), write:
=CONCATENATE("('",A2,"','",B2,"','",C2,"'),")

Related

Excel 2016 Array formula

I have the following formula in excel (created by me in the past),
=IFERROR(INDEX(Tasks!$H$2:$H$65536;SMALL(IF(A2=Tasks!$A$2:$A$65536;ROW(Tasks!$A$2:$A$65536)-ROW(Tasks!$A$2)+1);ROW($1:$1)));"")
The formula is working as I wanted, but in each and every month the a columns are changing, so for example what was Column "A" here can be Column "C" next month and so the number of rows are changing. I'm trying to modify the formula that I don't have to adjust month by month.
For this first I found a VBA script online:
Function Col_Letter(lngCol As Long) As String
Dim vArr
vArr = Split(Cells(1, lngCol).Address(True, False), "$")
Col_Letter = vArr(0)
End Function
So after if I type for example:
=Col_Letter(COLUMN(Table8[[#Headers];[ID]])) it will give me Letter "B" as this header can be found in "B" Column.
So using the advantage of this VBA script I was trying to create a formula what will adjust the column letter in the original formula every time.
So this formula:
=("Tasks!" & "$" & Col_Letter(COLUMN(Table32[[#Headers];[Owned By]])) & "$" & "2" & ":" & "$" & Col_Letter(COLUMN(Table32[[#Headers];[Owned By]])) & "$" & ROW(INDEX(Table32;1;1))+ROWS(Table32)-1) is giving me this as the result Tasks!$H$2:$H$65536.
what is part of the formula so I think it's good.
This is the whole formula I was trying to re-create in this manner:
=Index((("Tasks!" & "$" & Col_Letter(COLUMN(Table32[[#Headers];[Owned By]])) & "$" & ROW() & ":" & "$" & Col_Letter(COLUMN(Table32[[#Headers];[Owned By]])) & "$" & ROW(INDEX(Table32;1;1))+ROWS(Table32)-1);SMALL(IF((((Col_Letter(COLUMN(Table8[[#Headers];[ID]])) & ROW()) & "=" & (("Tasks!" & "$" & Col_Letter(COLUMN(Table32[[#Headers];[ID]])) & "$" & "2"& ":" & "$" & Col_Letter(COLUMN(Table32[[#Headers];[ID]])) & "$" & ROW(INDEX(Table32;1;1))+ROWS(Table32)-1))));Row((("Tasks!" & "$" & Col_Letter(COLUMN(Table32[[#Headers];[ID]])) & "$" & "2"& ":" & "$" & Col_Letter(COLUMN(Table32[[#Headers];[ID]])) & "$" & ROW(INDEX(Table32;1;1))+ROWS(Table32)-1)))-ROW(("Tasks!" & "$" & Col_Letter(COLUMN(Table32[[#Headers];[ID]])) & "$" & "2"))+1);ROWS($1:$1))))
Excel Tables have the potential of resolving such questions easily. Since the Columns can be referred by their names, you do not have to worry where they are located. And likewise, since you reference the data by column name but not row number, your reference will be covering all of the rows within that Table, no matter how many rows are added or deleted.
So as a start, try converting your range to Table by selecting it and use Insert / Table. After this you should convert your formula to contain Table references rather than cell references.

Paste values from 3 cells into one cell with delimiters in excel

I have the following data where A to C are the columns:
A B C
-5.274 -20.63 9.251
where each number is in a different cell.
I want to combine these numbers in the following way and paste them into a new cell (those of column D)
-5.274 (-20.63 − 9.251)
How can I do this?
You can't copy and paste them like that, but you can very easily:
D2: =A2 & " (" & B2 & " - " & C2 & ")"
To keep the formatting:
=TEXT(A1;"0.00")& "(" & TEXT(B1;"0.00") & " " & TEXT(C1;"0.00") & ")"

Indirect function in array with if statement

I have the following function
=IF([A68U.SI.csv]A68U.SI!$G$3:$G$1000="","",[A68U.SI.csv]A68U.SI!$G$3:$G$1000)
Here, I would like to replace A68U.SI with the entry in cell C1, which contains the text "A68U.SI".
I tried the following formula but am getting an error:
=IF((INDIRECT("[" & C1 & ".csv]" & C1 & "!"))$G$3:$G$1000="","",INDIRECT("[" & C1 & ".csv]" & C1 & "!"))$G$3:$G$1000)
Does anyone have an idea what's wrong?
As always, many thanks!
try
=iferror(IF((INDIRECT("[" & C1 & ".csv]" & C1 & "!"))$G$3:$G$1000="","",INDIRECT("[" & C1 & ".csv]" & C1 & "!"))$G$3:$G$1000),"Please open the file "&C1&".csv")

Excel: Formula Returning from conditional

How to return formula of other cell (column L) if choose item in column A.
Example:
if answer, then return =I5 & " " & J5
if foo, then return '=I7 & " " & J7 & " " & K7 & " x " & L7
I want to return the formula instead of the result.
Put this function in a public module
Function GetFormula(rng As Range) As Variant
GetFormula = rng.Formula
End Function
I think this is what you want. There are several options for how you want that formula returned such as R1C1 style.
Edit
Oh I think I get what you want more. Ok to apply the formula you have in your blue table to whatever cell you want in column F you can call the Indirect function.
So for example if you want to apply the formula '=I7 & " " & J7 & " " & K7 & " x " & L7 to your column F then call =INDIRECT(I7 & " " & J7 & " " & K7 & " x " & L7). In your column I don't include the = sign. it will make it a bit easier.
You can use Vlookup to find where this should be applied by using your lookup item in column A in your reference table (the blue table). Return the formula in column I.
You can achieve this by nesting your formulas.
put this in E5
=IF(A5 = "answer", A5 & " " & B5 & " " & D5,
IF(A5 = "bar", A5 & " " & B5 & " " & C5,
IF(A5 = "foo", A5 & " " & B5,
"No If Formula Here yet")))
I started the formula off with the first two formatting's for you.

Concatenating Fields in Excel

I have an Excel Document that has Table Names in Column A and Column Names in Column B.
A1 B1
Account Account_ID
I can get the syntax correct.
The formula is:
=CONCATENATE("Select '",$A$1,"','",B1,"',",B1,", count(*) From ",$A$1, " group by '",",B1,";")
The output that I get is:
Select 'ACCOUNT','ACCOUNT_ID',ACCOUNT_ID, count(*) From ACCOUNT group by 'ACCOUNT','ACCOUNT_ID',ACCOUNT_ID;
The output that I need is:
Select 'ACCOUNT','ACCOUNT_ID',ACCOUNT_ID, count(*) From ACCOUNT group by ACCOUNT_ID;
Any help would be greatly appreciated.
Try concatenation using the ampersand.
You can link together string literals and cell contents as such.
="String1" & "'" & "String2"
will result in
String1'String2
So to try and build sql statements from excel cells, lets say you have an excel sheet with tables and fields
A B C
1 Table1 Column1 Column2
2 Table2 COlumn1 Column2
You can build sql statements from those values
="SELECT 'Table1', " & B1 & ", " & C1 & " FROM " & A1
="SELECT 'Table2', " & B2 & ", " & C2 & " FROM " & A2
Will yield
SELECT 'Table1', Column1, Column2 FROM Table1
SELECT 'Table2', Column1, Column2 FROM Table2
The quotes specify Strings and the apersand (&) joins them together. Anything outside a set of strings will be evaluated.
For example a string with a bunch of spaces could be trimmed and joined
= TRIM(A1) & " Trimmed"
would yield
Table1 Trimmed
Your particular example would look like so
="SELECT '" & A1 & "', '" & B1 & "', Account_ID, COUNT(*) FROM " & A1 & " GROUP BY " & B1

Resources