Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default How to I put a comma in between each column item from this code

This code combines all the data into one string. How can I parse it with a
comma in between each column entry.

Also would there be a way to add comments to each column right before the
comma?? Thanks

Set x = CreateObject("Word.Application")
x.Documents.Add
x.Visible = True

For Each cl In Selection

n = n & CStr(cl.Value)

Next

x.Selection.TypeText CStr(n)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default How to I put a comma in between each column item from this code

On Mon, 7 Mar 2005 20:51:02 -0800, "Adam"
wrote:

This code combines all the data into one string. How can I parse it with a
comma in between each column entry.

Also would there be a way to add comments to each column right before the
comma?? Thanks

Set x = CreateObject("Word.Application")
x.Documents.Add
x.Visible = True

For Each cl In Selection

n = n & CStr(cl.Value)

Next

x.Selection.TypeText CStr(n)


Here's one way:

=======================
Sub foo()
Dim temp()
Dim n As String
Dim c As Range
Dim i As Long

ReDim temp(Selection.Count - 1)
For Each c In Selection
temp(i) = CStr(c.Value)
i = i + 1
Next c

n = Join(temp, ",")

Debug.Print n
End Sub
=========================


--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I add an item with comma in the list of data validation bhavna Excel Discussion (Misc queries) 9 October 2nd 08 04:13 PM
Creating a column with just data before comma in another column Help with text manipulation Excel Worksheet Functions 2 November 18th 07 06:18 PM
enter item code in one column, automatically get description in ne Shelley Kingston Excel Worksheet Functions 2 July 19th 06 12:32 PM
Selecting Menu Item by VBA Code PosseJohn Excel Programming 2 December 5th 04 12:24 PM
Select an item in a listbox using code Fred Jacobowitz Excel Programming 2 August 23rd 04 03:27 AM


All times are GMT +1. The time now is 09:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"