I have a concat formula returning me a comma separated list of names in a cell
=concat(A2:A10 & " ,") returning [john, jack, jill] in the cell
Is there a way to add to this formula to expand to
john
jack
jill
in a column like that above?
You can change the separator to be a line break =CONCAT(A2:A10 & CHAR(10)) or =TEXTJOIN(CHAR(10),TRUE,P3:P5)
The target cell needs to be set to Wrap Text for the line breaks to be displayed correctly.
I used Power Editor to convert the cell into rows
I have a userform that has a list of numbers entered in column style with no separator other than being on a separate line. Entry into the user form will look something like this:
2172223333
2172223334
2172223335
2172223336
2172223337
How do I use the SPLIT function to separate this bulk entry into the user form into separate cells in the same column on a spreadsheet? I'm familiar with how it works if there is a comma or space to look for between the terms but will it somehow recognize a separate line as a delineator and if so, what symbol do I use to represent that in the code?
I want to be able to read this input and have it entered in a workbook, say ("workbookA") and sheets(1) and put it in Column A starting at row 2 and going downward staying in column A.
Try this:
myString = ...
data = split(myString, vbcrlf)
workbooks("workbookA").worksheets(1).range("A2").resize(ubound(data)+1,1).value = application.transpose(data)
myString is the String with your data.
In VBA you have the constants vbLf, vbCr, vbCrLf for linefeed, carriage return and linefeed + carriage return (https://en.wikipedia.org/wiki/Newline), which represent the characters.
I have the task of creating a simple Excel sheet that takes an unspecified number of rows in Column A like this:
1-10-13
1-12-3
1-15-13
And make them into a comma-separated list in another cell that the user can easily copy and paste into another program like so:
1-10-13,1-12-3,1-15-13
This can be done by and draging down:
=B1&","&A2
However, I need the output to be like such:
GIS_ID in ('WV-1-10-13', 'WV-51-1-12-3', 'WV-1-15-13')
Basically, I need to prepend the whole thing with GIS_ID in ( and then insert WV- before each value AND put each in single '' quotes. Please help. Thanks.
With data in A1 through A3, use:
="GIS_ID in ('WV-" & TEXTJOIN("', 'WV-",TRUE,A1:A3) & "')"
The formula can easily be expanded to handle more than three cells.
I have a comma delimited string (aad,adaa,,dadae,,,eresa,,baaa) in cell A1 of Sheet1 which I want to split and insert values in a column such as:
aad
adaa
dadae
eresa
baaa
Empty values will skip a cell and insert the string in next cell.
I am able to separate the string to a row but how could I do it to a column?
Here is my line to split the string to a row:
Sheets("Sheet1").Range("A1").TextToColumns
Call WorksheetFunction.Transpose() after splitting to columns.
No need to use TextToColumns either, Split will suffice:
Range("A1:A9").value = WorksheetFunction.Transpose(Split("aad,adaa,,dadae,,,eresa,,baaa", ","))
E.g
A1:I
A2:am
A3:a
A4:boy
I want to merge them all to a single cell "Iamaboy"
This example shows 4 cells merge into 1 cell however I have many cells (more than 100), I can't type them one by one using A1 & A2 & A3 & A4 what can I do?
If you prefer to do this without VBA, you can try the following:
Have your data in cells A1:A999 (or such)
Set cell B1 to "=A1"
Set cell B2 to "=B1&A2"
Copy cell B2 all the way down to B999 (e.g. by copying B2, selecting cells B3:B99 and pasting)
Cell B999 will now contain the concatenated text string you are looking for.
I present to you my ConcatenateRange VBA function (thanks Jean for the naming advice!) . It will take a range of cells (any dimension, any direction, etc.) and merge them together into a single string. As an optional third parameter, you can add a seperator (like a space, or commas sererated).
In this case, you'd write this to use it:
=ConcatenateRange(A1:A4)
Function ConcatenateRange(ByVal cell_range As range, _
Optional ByVal separator As String) As String
Dim newString As String
Dim cell As Variant
For Each cell in cell_range
If Len(cell) <> 0 Then
newString = newString & (separator & cell)
End if
Next
If Len(newString) <> 0 Then
newString = Right$(newString, (Len(newString) - Len(separator)))
End If
ConcatenateRange = newString
End Function
Inside CONCATENATE you can use TRANSPOSE if you expand it (F9) then remove the surrounding {}brackets like this recommends
=CONCATENATE(TRANSPOSE(B2:B19))
Becomes
=CONCATENATE("Oh ","combining ", "a " ...)
You may need to add your own separator on the end, say create a column C and transpose that column.
=B1&" "
=B2&" "
=B3&" "
In simple cases you can use next method which doesn`t require you to create a function or to copy code to several cells:
In any cell write next code
=Transpose(A1:A9)
Where A1:A9 are cells you would like to merge.
Without leaving the cell press F9
After that, the cell will contain the string:
={A1,A2,A3,A4,A5,A6,A7,A8,A9}
Source: http://www.get-digital-help.com/2011/02/09/concatenate-a-cell-range-without-vba-in-excel/
Update: One part can be ambiguous. Without leaving the cell means having your cell in editor mode. Alternatevly you can press F9 while are in cell editor panel (normaly it can be found above the spreadsheet)
Use VBA's already existing Join function. VBA functions aren't exposed in Excel, so I wrap Join in a user-defined function that exposes its functionality. The simplest form is:
Function JoinXL(arr As Variant, Optional delimiter As String = " ")
'arr must be a one-dimensional array.
JoinXL = Join(arr, delimiter)
End Function
Example usage:
=JoinXL(TRANSPOSE(A1:A4)," ")
entered as an array formula (using Ctrl-Shift-Enter).
Now, JoinXL accepts only one-dimensional arrays as input. In Excel, ranges return two-dimensional arrays. In the above example, TRANSPOSE converts the 4×1 two-dimensional array into a 4-element one-dimensional array (this is the documented behaviour of TRANSPOSE when it is fed with a single-column two-dimensional array).
For a horizontal range, you would have to do a double TRANSPOSE:
=JoinXL(TRANSPOSE(TRANSPOSE(A1:D1)))
The inner TRANSPOSE converts the 1×4 two-dimensional array into a 4×1 two-dimensional array, which the outer TRANSPOSE then converts into the expected 4-element one-dimensional array.
This usage of TRANSPOSE is a well-known way of converting 2D arrays into 1D arrays in Excel, but it looks terrible. A more elegant solution would be to hide this away in the JoinXL VBA function.
For those who have Excel 2016 (and I suppose next versions), there is now directly the CONCAT function, which will replace the CONCATENATE function.
So the correct way to do it in Excel 2016 is :
=CONCAT(A1:A4)
which will produce :
Iamaboy
For users of olders versions of Excel, the other answers are relevant.
For Excel 2011 on Mac it's different. I did it as a three step process.
Create a column of values in column A.
In column B, to the right of the first cell, create a rule that uses the concatenate function on the column value and ",". For example, assuming A1 is the first row, the formula for B1 is =B1. For the next row to row N, the formula is =Concatenate(",",A2). You end up with:
QA
,Sekuli
,Testing
,Applitools
,Visual Testing
,Test Automation
,Selenium
In column C create a formula that concatenates all previous values. Because it is additive you will get all at the end. The formula for cell C1 is =B1. For all other rows to N, the formula is =Concatenate(C1,B2). And you get:
QA,Sekuli
QA,Sekuli,Testing
QA,Sekuli,Testing,Applitools
QA,Sekuli,Testing,Applitools,Visual Testing
QA,Sekuli,Testing,Applitools,Visual Testing,Test Automation
QA,Sekuli,Testing,Applitools,Visual Testing,Test Automation,Selenium
The last cell of the list will be what you want. This is compatible with Excel on Windows or Mac.
I use the CONCATENATE method to take the values of a column and wrap quotes around them with columns in between in order to quickly populate the WHERE IN () clause of a SQL statement.
I always just type =CONCATENATE("'",B2,"'",",") and then select that and drag it down, which creates =CONCATENATE("'",B3,"'",","), =CONCATENATE("'",B4,"'",","), etc. then highlight that whole column, copy paste to a plain text editor and paste back if needed, thus stripping the row separation. It works, but again, just as a one time deal, this is not a good solution for someone who needs this all the time.
I know this is really a really old question, but I was trying to do the same thing and I stumbled upon a new formula in excel called "TEXTJOIN".
For the question, the following formula solves the problem
=TEXTJOIN("",TRUE,(a1:a4))
The signature of "TEXTJOIN" is explained as TEXTJOIN(delimiter,ignore_empty,text1,[text2],[text3],...)
I needed a general purpose Concatenate With Separator (since I don't have TEXTJOIN) so I wrote this:
Public Function ConcatWS(separator As String, ParamArray cell_range()) As String
'---concatenate with seperator
For n = LBound(cell_range) To UBound(cell_range)
For Each cell In cell_range(n)
If Len(cell) <> 0 Then
ConcatWS = ConcatWS & IIf(ConcatWS <> "", separator, "") & cell
End If
Next
Next n
End Function
Which allows us to go crazy with flexibility in including cell ranges:
=ConcatWS(" ", Fields, E1:G2, L6:M9, O6)
NOTE: "Fields" is a Named Range and the separator may be blank