Joining a range as a string

jts2004

Board Regular
Joined
Apr 21, 2004
Messages
156
A1:B10 has random numbers words or letters. I want to concatenate them into one cell w/o using multiple "&" strings
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Then you would have to write a user defined function as follows

function concatthemall(a as range) as string
for each b in a
concatthemall=concatthemall & b.value
next
end function

then use =concatthemall(a1:b10) to combine them
 
Upvote 0
It works. I like this user defined stuff! where do I get info on it. If I givethis spreadsheet to someone on a different PC does the function go with the file?
 
Upvote 0
jts2004 said:
It works. I like this user defined stuff! where do I get info on it. If I givethis spreadsheet to someone on a different PC does the function go with the file?

If you put the function ina module that is part of the spreadsheet then yes it will work. If you put th efunction in your personal workbook then no it will not work.

And Yee388 - Very witty but the answer is obvious... To make a bigger mall (y)
 
Upvote 0
Always wondered that myself, lets bump this back to the top and see if anybody has an answer.

Can you control whether a for each loop referring to each cell in a range reads across rows or down columns?
 
Upvote 0
I don't think you can change the order of an Each command... this is how I would make it go down a list from A1:B10:

Code:
Sub TestOrder()

For c = 1 To 2
    For r = 1 To 10
        Cells(r, c) = 1
    Next r
Next c

End Sub
 
Upvote 0
The only way that I can think is to do them seperately i.e.

=concatthemall(A1:A10) placed in say E1
=concatthemall(B1:B10) placed in F1

and assume ing that C1 is where you want the answer then

=E1 & F1 will do the job
(y)
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,114,002
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top