--There are "&" and "CONCATENATE ()" in the method of string concatenation in Excel.
--However, both methods require you to specify each cell individually.
- =A1&A2&A3
- =CONCATENATE(A1,A2,A3)
――I can't select a range even though I have a function (what is the function really for?)
--There is a site that describes VBA that makes this range selectable.
――In addition to simple string concatenation, in my case, I thought that it would be more convenient to be able to concatenate strings in the following cases, so I created a function with reference to the above site.
--I've been using functions for over 5 years now, but it's very convenient and I use them quite often.
No | language | Purpose | String concatenation method |
---|---|---|---|
1 | SQL | Mass selection of columns | Delimiter "comma" |
2 | SQL | Mass generation of CASE statements | Delimiter "space" |
3 | Markdown | Create table | Delimiter "pipe" |
4 | R, Python | Define header | Delimiter "comma" quote "single quote" |
--There are many articles on the net, so please check them yourself.
Excel
A | B | C | |
---|---|---|---|
1 | dt | ||
2 | product | ||
3 | price |
=ConcatenateRangeText_comma(B1:B3)
dt,product,price
Excel
A | B | C | D | E | F | |
---|---|---|---|---|---|---|
1 | ,SUM(CASE WHEN product = | 'car' | THEN 1 ELSE 0 END) AS | product_car | ||
2 | ,SUM(CASE WHEN product = | 'bike' | THEN 1 ELSE 0 END) AS | product_bike |
=ConcatenateRangeText_space(B1:E1)
=ConcatenateRangeText_space(B2:E2)
,SUM(CASE WHEN product = 'car' THEN 1 ELSE 0 END) AS product_car
,SUM(CASE WHEN product = 'bike' THEN 1 ELSE 0 END) AS product_bike
Excel
A | B | C | D | |
---|---|---|---|---|
1 | 2 | SQL | ||
2 | 3 | Markdown | ||
3 | 4 | R,Python |
=ConcatenateRangeText_separator(A1:D1,"|")
=ConcatenateRangeText_separator(A2:D2,"|")
=ConcatenateRangeText_separator(A3:D3,"|")
|2|SQL|
|3|Markdown|
|4|R,Python|
Excel
A | B | C | |
---|---|---|---|
1 | dt | ||
2 | product | ||
3 | price |
=ConcatenateRangeText_singlequote_comma(B1:B3)
'dt','product','price'
――We have some code similar to this.