Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Add to a string to make it continuous

I currently have a spreadsheet that has an infinate number of rows determined
by the user.

The code states:

For row=7 to Worksheets('Example').UsedRange.Row.Count

String1 = Worksheets("Example").Cells.(Row,1).Value

Endfor

Now I am trying to accomplish it to just add to the string opposed to just
creating a new line each time. This information is finally outputted to Word.

For example: What I want
Column

Apples
Oranges
Peaches

to look like: Apples, Oranges, Peaches

What I get:

Apples, Oranges, Peaches
Apples, Oranges
Apples

is the current output. Any suggestions? Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Add to a string to make it continuous

Adam,

Change
String1 = Worksheets("Example").Cells.(Row,1).Value
to
String1 = String1 & Worksheets("Example").Cells.(Row,1).Value


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Adam" wrote in message
...
I currently have a spreadsheet that has an infinate number of
rows determined
by the user.

The code states:

For row=7 to Worksheets('Example').UsedRange.Row.Count

String1 = Worksheets("Example").Cells.(Row,1).Value

Endfor

Now I am trying to accomplish it to just add to the string
opposed to just
creating a new line each time. This information is finally
outputted to Word.

For example: What I want
Column

Apples
Oranges
Peaches

to look like: Apples, Oranges, Peaches

What I get:

Apples, Oranges, Peaches
Apples, Oranges
Apples

is the current output. Any suggestions? Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Add to a string to make it continuous

Sorry, but this function does not work. It still cascades it down showing

Apples, Oranges, Peaches
Apples, Oranges
Apples

"Chip Pearson" wrote:

Adam,

Change
String1 = Worksheets("Example").Cells.(Row,1).Value
to
String1 = String1 & Worksheets("Example").Cells.(Row,1).Value


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Adam" wrote in message
...
I currently have a spreadsheet that has an infinate number of
rows determined
by the user.

The code states:

For row=7 to Worksheets('Example').UsedRange.Row.Count

String1 = Worksheets("Example").Cells.(Row,1).Value

Endfor

Now I am trying to accomplish it to just add to the string
opposed to just
creating a new line each time. This information is finally
outputted to Word.

For example: What I want
Column

Apples
Oranges
Peaches

to look like: Apples, Oranges, Peaches

What I get:

Apples, Oranges, Peaches
Apples, Oranges
Apples

is the current output. Any suggestions? Thanks





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Add to a string to make it continuous

This did not seem to work either.

"Don Guillett" wrote:

try
Sub stringem()
For Each C In Range("e2:e" & Cells(Rows.Count, "e").End(xlUp).Row)
mystring = mystring & C & ","
Next
MsgBox Left(mystring, Len(mystring) - 1)

End Sub

--
Don Guillett
SalesAid Software

"Adam" wrote in message
...
I currently have a spreadsheet that has an infinate number of rows

determined
by the user.

The code states:

For row=7 to Worksheets('Example').UsedRange.Row.Count

String1 = Worksheets("Example").Cells.(Row,1).Value

Endfor

Now I am trying to accomplish it to just add to the string opposed to just
creating a new line each time. This information is finally outputted to

Word.

For example: What I want
Column

Apples
Oranges
Peaches

to look like: Apples, Oranges, Peaches

What I get:

Apples, Oranges, Peaches
Apples, Oranges
Apples

is the current output. Any suggestions? Thanks







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Add to a string to make it continuous

Did you try my suggestion?

--
Don Guillett
SalesAid Software

"Adam" wrote in message
...
Sorry, but this function does not work. It still cascades it down showing

Apples, Oranges, Peaches
Apples, Oranges
Apples

"Chip Pearson" wrote:

Adam,

Change
String1 = Worksheets("Example").Cells.(Row,1).Value
to
String1 = String1 & Worksheets("Example").Cells.(Row,1).Value


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Adam" wrote in message
...
I currently have a spreadsheet that has an infinate number of
rows determined
by the user.

The code states:

For row=7 to Worksheets('Example').UsedRange.Row.Count

String1 = Worksheets("Example").Cells.(Row,1).Value

Endfor

Now I am trying to accomplish it to just add to the string
opposed to just
creating a new line each time. This information is finally
outputted to Word.

For example: What I want
Column

Apples
Oranges
Peaches

to look like: Apples, Oranges, Peaches

What I get:

Apples, Oranges, Peaches
Apples, Oranges
Apples

is the current output. Any suggestions? Thanks







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Add to a string to make it continuous

Don't write to word inside the loop. Build the entire string, then write to
word one time.

--
Regards,
Tom Ogilvy


"Adam" wrote in message
...
This did not seem to work either.

"Don Guillett" wrote:

try
Sub stringem()
For Each C In Range("e2:e" & Cells(Rows.Count, "e").End(xlUp).Row)
mystring = mystring & C & ","
Next
MsgBox Left(mystring, Len(mystring) - 1)

End Sub

--
Don Guillett
SalesAid Software

"Adam" wrote in message
...
I currently have a spreadsheet that has an infinate number of rows

determined
by the user.

The code states:

For row=7 to Worksheets('Example').UsedRange.Row.Count

String1 = Worksheets("Example").Cells.(Row,1).Value

Endfor

Now I am trying to accomplish it to just add to the string opposed to

just
creating a new line each time. This information is finally outputted

to
Word.

For example: What I want
Column

Apples
Oranges
Peaches

to look like: Apples, Oranges, Peaches

What I get:

Apples, Oranges, Peaches
Apples, Oranges
Apples

is the current output. Any suggestions? Thanks







  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Add to a string to make it continuous

The latest versions of Excel might be able to do it this way. Just an
option:

Dim s As String
s = Join(WorksheetFunction.Transpose(Range(Cells(7, 1),
Cells(Rows.Count, 1).End(xlUp))), ",")
Debug.Print s

--
Dana DeLouis
Win XP & Office 2003


"Adam" wrote in message
...
I got your code to work. Thanks!!

"Don Guillett" wrote:

Fully tested. How did you modify to suit your needs.

--
Don Guillett
SalesAid Software

"Adam" wrote in message
...
This did not seem to work either.

"Don Guillett" wrote:

try
Sub stringem()
For Each C In Range("e2:e" & Cells(Rows.Count, "e").End(xlUp).Row)
mystring = mystring & C & ","
Next
MsgBox Left(mystring, Len(mystring) - 1)

End Sub

--
Don Guillett
SalesAid Software

"Adam" wrote in message
...
I currently have a spreadsheet that has an infinate number of rows
determined
by the user.

The code states:

For row=7 to Worksheets('Example').UsedRange.Row.Count

String1 = Worksheets("Example").Cells.(Row,1).Value

Endfor

Now I am trying to accomplish it to just add to the string opposed
to

just
creating a new line each time. This information is finally
outputted

to
Word.

For example: What I want
Column

Apples
Oranges
Peaches

to look like: Apples, Oranges, Peaches

What I get:

Apples, Oranges, Peaches
Apples, Oranges
Apples

is the current output. Any suggestions? Thanks












  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Add to a string to make it continuous

Nice. Worked in xl2002 but join is not in xl97

--
Don Guillett
SalesAid Software

"Dana DeLouis" wrote in message
...
The latest versions of Excel might be able to do it this way. Just an
option:

Dim s As String
s = Join(WorksheetFunction.Transpose(Range(Cells(7, 1),
Cells(Rows.Count, 1).End(xlUp))), ",")
Debug.Print s

--
Dana DeLouis
Win XP & Office 2003


"Adam" wrote in message
...
I got your code to work. Thanks!!

"Don Guillett" wrote:

Fully tested. How did you modify to suit your needs.

--
Don Guillett
SalesAid Software

"Adam" wrote in message
...
This did not seem to work either.

"Don Guillett" wrote:

try
Sub stringem()
For Each C In Range("e2:e" & Cells(Rows.Count, "e").End(xlUp).Row)
mystring = mystring & C & ","
Next
MsgBox Left(mystring, Len(mystring) - 1)

End Sub

--
Don Guillett
SalesAid Software

"Adam" wrote in message
...
I currently have a spreadsheet that has an infinate number of

rows
determined
by the user.

The code states:

For row=7 to Worksheets('Example').UsedRange.Row.Count

String1 = Worksheets("Example").Cells.(Row,1).Value

Endfor

Now I am trying to accomplish it to just add to the string

opposed
to
just
creating a new line each time. This information is finally
outputted
to
Word.

For example: What I want
Column

Apples
Oranges
Peaches

to look like: Apples, Oranges, Peaches

What I get:

Apples, Oranges, Peaches
Apples, Oranges
Apples

is the current output. Any suggestions? Thanks












  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Add to a string to make it continuous

Added in xl2k.

Don Guillett wrote:

Nice. Worked in xl2002 but join is not in xl97

--
Don Guillett
SalesAid Software

"Dana DeLouis" wrote in message
...
The latest versions of Excel might be able to do it this way. Just an
option:

Dim s As String
s = Join(WorksheetFunction.Transpose(Range(Cells(7, 1),
Cells(Rows.Count, 1).End(xlUp))), ",")
Debug.Print s

--
Dana DeLouis
Win XP & Office 2003


"Adam" wrote in message
...
I got your code to work. Thanks!!

"Don Guillett" wrote:

Fully tested. How did you modify to suit your needs.

--
Don Guillett
SalesAid Software

"Adam" wrote in message
...
This did not seem to work either.

"Don Guillett" wrote:

try
Sub stringem()
For Each C In Range("e2:e" & Cells(Rows.Count, "e").End(xlUp).Row)
mystring = mystring & C & ","
Next
MsgBox Left(mystring, Len(mystring) - 1)

End Sub

--
Don Guillett
SalesAid Software

"Adam" wrote in message
...
I currently have a spreadsheet that has an infinate number of

rows
determined
by the user.

The code states:

For row=7 to Worksheets('Example').UsedRange.Row.Count

String1 = Worksheets("Example").Cells.(Row,1).Value

Endfor

Now I am trying to accomplish it to just add to the string

opposed
to
just
creating a new line each time. This information is finally
outputted
to
Word.

For example: What I want
Column

Apples
Oranges
Peaches

to look like: Apples, Oranges, Peaches

What I get:

Apples, Oranges, Peaches
Apples, Oranges
Apples

is the current output. Any suggestions? Thanks











--

Dave Peterson
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
make continuous list of days of week without Sunday pb.admin Excel Discussion (Misc queries) 1 October 9th 09 04:04 PM
how do i make a continuous data table gazman Excel Discussion (Misc queries) 0 May 28th 08 02:48 AM
How do I make letters not show up in a alpha-numeric string? gdd6936 Excel Worksheet Functions 3 June 3rd 06 09:56 PM
How do I make this string bold? Adam Excel Programming 1 March 9th 05 02:56 AM
make string variable reference VBA sheet name Tom Deiley Excel Programming 5 May 3rd 04 10:45 PM


All times are GMT +1. The time now is 10:03 PM.

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"