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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

boxsterman

Active Member
Joined
Apr 16, 2002
Messages
279
Try =concatenate(a1,a2,a3,a4,a5,a6,....b10)

or did you want to avoid all the typing?
 

cherria

Well-known Member
Joined
Nov 17, 2004
Messages
708
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
 

jts2004

Board Regular
Joined
Apr 21, 2004
Messages
156
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?
 

yee388

Well-known Member
Joined
Mar 7, 2004
Messages
1,374

ADVERTISEMENT

Why would you want to concatenate the mall?

:wink
 

cherria

Well-known Member
Joined
Nov 17, 2004
Messages
708
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)
 

jts2004

Board Regular
Joined
Apr 21, 2004
Messages
156

ADVERTISEMENT

How do you get the range to read down instead of across
 

cherria

Well-known Member
Joined
Nov 17, 2004
Messages
708
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?
 

yee388

Well-known Member
Joined
Mar 7, 2004
Messages
1,374
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
 

Whisperer14

Well-known Member
Joined
Nov 6, 2002
Messages
589
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)
 

Forum statistics

Threads
1,147,510
Messages
5,741,574
Members
423,668
Latest member
Audorin

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
Top