Copy Name Range in single Cell

D

Dhimant

Hi,

I had create a NameRange from Insert > Define > Name

That is fro say from a1:a5

Now I want to copy all a1:a5 in cell B1.

Can any one halp me?

Thanks in advance
 
D

Don Guillett

Are you saying that if a1:a5 has a,b,c,d then you want cell b1 to say
a,b,c,d in one cell? Spaces?, Be SPECIFIC.
 
D

Dhimant

yes it should be like a,b,c,d
--
India


Don Guillett said:
Are you saying that if a1:a5 has a,b,c,d then you want cell b1 to say
a,b,c,d in one cell? Spaces?, Be SPECIFIC.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
 
K

keiji kounoike

If your data reside in only one column and the name of the range is fro,
try this one. but this one doesn't work if your data reside in multiple
columns.

Sub test()
Dim arr
arr = Application.Transpose(Range("fro"))
Range("fro").Offset(0, 1).Resize(1, 1) = join(arr, ",")
End Sub

keiji
 
D

Dhimant

Dear Keiji,

its working....But will it possible to convert it into functin?
i mean if i write =abc(arr) and the reasult will be a,b,c,d,e
 
G

Gord Dibben

Function ConCatRange(CellBlock As Range) As String
Dim Cell As Range
Dim sbuf As String
For Each Cell In CellBlock
If Len(Cell.text) > 0 Then sbuf = sbuf & Cell.text & ","
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function

=concatrange(fro)

Or just =concatrange(a1:a5)


Gord Dibben MS Excel MVP
 

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