Results 1 to 2 of 2
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA Help (97 SR2)

    How would I append all selected cells into one, separated by a comma?

    For example, I've got a list of items:

    Tree
    Truck
    Car

    After the macro runs, I get "Tree, Truck, Car", in the first selected Cell.

    Any ideas?
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA Help (97 SR2)

    Something like this:

    <pre>Public Sub ConcatSel()
    Dim oCell As Range, strWk As String
    For Each oCell In Selection
    strWk = strWk & oCell & ", "
    Next oCell
    ActiveCell.Value = Trim(Left(strWk, Len(strWk) - 2))
    End Sub
    </pre>

    Legare Coleman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •