Jululian & Excel

  • Thread starter George A. Jululian
  • Start date
G

George A. Jululian

Dear All,

I have one colum and 30 rows
and i want to put all in one cell and i am using
A1&A2&A3

please advice if there is any other soultion

regards
 
P

Pete_UK

You could put this in B1:

=A1

and then put this in B2

=B1&A2

Copy this down to B30, and this final cell will contain the composite
string.

Hope this helps.

Pete
 
G

Gary''s Student

It would be nice if there was a function like =SUM() that would concatenate
vlues rather than sum them. We can make such a function (User Defined
Function):

Function concat(r As Range) As String
Dim rr As Range
concat = ""
For Each rr In r
concat = concat & rr.Value
Next
End Function



User Defined Functions (UDFs) are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the UDF will be saved with it.

To remove the UDF:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To use the UDF from Excel:

=concat(A1:A30)

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

or

http://www.cpearson.com/excel/WritingFunctionsInVBA.aspx
for specifics on UDFs
 
J

JLatham

we could even expand on that to give it the ability to put a "delimiter" or
separator between each non-empty cell's values in the result:

Function concatplus(r As Range) As String
Dim rr As Range
Const delimiter = " " ' could change to ", "," if desired
concatplus = ""
For Each rr In r
If Not IsEmpty(rr) Then
concatplus = concatplus & rr.Value & delimiter
End If
Next
If Len(concatplus) > 0 Then
'remove last, unnecessary delimiter
concatplus = Left(concatplus, _
Len(concatplus) - Len(delimiter))
End If
End Function
 
G

George A. Jululian

First of all many thank

please advice where i wirte them or how can use the

regards
 
G

George A. Jululian

First of all many thank

please advice where i wirte them or how can use them

regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top