Reputation: 71
I have a situation where I have 123 columns of data and out of those 123 colums, only up to 6 of them will be poplated with data. I need to collect all the fields that do have data and put them into one cell.
I found this article, How to merge rows in a column into one cell in excel?, on stackoverflow but it still is not quite what I am looking for and I could not get the =transpose solution to work as suggested at the bottom of the thread. I found a 3rd party solution that was a plugin for Excel but it is only for Windows and I have Office for Mac.
So I desperately need to know how to do this. I'am not showing 123 columns but I think you get the idea. http://grab.by/BwDu
=concatenate(text,text,text...) is not an option because even if I wanted to put all 123 fields in here i am still faced with the problem of the formula putting in a space or comma in place of a blank field.
Upvotes: 1
Views: 1089
Reputation: 35680
The ConcatenateRange function at the link you posted seems to accomplish what you want.
If you prefer a formula, this works for your example data:
=SUBSTITUTE(
TRIM(
B1&" "&C1&" "&D1&" "&E1&" "&F1&" "&G1&" "&H1&" "&I1&" "&J1&" "&
K1&" "&L1&" "&M1&" "&N1&" "&O1&" "&P1&" "&Q1&" "&R1&" "&S1
),
" ",
","
)
Output:
cat,bird,dog,mouse,horse,elephant,chimp,lion,sloth,zebra,geraf,snake,grasshopper
This formula concatenates the data with spaces. TRIM
changes multiple spaces to single spaces, and SUBSTITUTE
replaces all the spaces with commas.
To reach 123 columns, you'll simply need to continue adding cells.
Upvotes: 1