View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Anant Basant Anant Basant is offline
external usenet poster
 
Posts: 30
Default Values from a range in one cell, seperated

Hi,

I have these four values in a worksheet range A1:A4

Name1
Name2
Name3
Name4

I select the range of cells and run the following macro:

Sub ConcatData()
Dim myStr As String
Dim c As Range

For Each c In Selection.Cells
If Not IsEmpty(c) Then
myStr = myStr & "; " & c.Value
End If
Next c
myStr = Right(myStr, Len(myStr) - 2)
End Sub

--
Anant


"jgmiddel" wrote:

In a range "stores" I have some values. What I want is to put all this
data in one cell, seperated by a ";" and a space. If there is only one
row filled in, that ";" should not be placed. Can anyone help? Thanks
in advance.