I have a couple hundred of cells in Excel I would like to concatenate into a single string. Is there a simpler method of doing this than going through them one by one manually in order to type them into CONCATENATE(A1, A2, ....)
?
CONCATENATE(A1:A255)
does not work.
Just add your deliminator in one concatenation:
Then copy all the concatenations, paste them as Values. Then Copy those Values, paste them in a transposition. Then copy the Transposed values and paste them into a word editor. Do a find for the deliminator AND the space preceding the values and do a replace for JUST the deliminator. This should give you a concatenated string of all the values with a deliminator. This is much easier than other options.
If your looking for a pure Excel approach (ie no VBA) then the method proposed by James Jenkins is best. If you are happy using VBA then open up the VBA editor, add a new module, and add this code:
To open the VBA editor easily press Alt-F11. To insert a module you right-click on the workbook listed in the 'Project' window.
The function is called from excel as follows:
If you want to add a delimiter (eg comma):
The purpose of using the transpose function is to turn the 2d array, 'cells', into a 1d array. The reson for this is that the VBA function Join only accepts a 1d array. The reason for using two of them is if JoinText is looking at a row of cells (which is still just a 2d array) then the first call to transpose, transposes this 2d row array into a 2d column array, the second call turns it into a 1d array.
Shamelessly copied from this site:
What is particularly revelatory here is that when editing a formula, pressing F9 replaces the formula with the result of that formula. Where that's a range, it replaces it with a list of the contents of that range.
If you have Excel 2016, you can use an array formula:
Enter
into the cell, then press
*In a new tab, type A1 in cell A1,
*Type A2 in Cell A2
*Use fill series to complete the values in column A
*Type A1 in cell B1
Use this forumal in cell B2
=B1&","&A2
Copy the formula down.
Copy and paste values to harvest the string of values you created.
Press
Alt-F11
, insert new module, paste code bellow.Usage:
or