Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VB code to concatenate 100+ cells

Hello,

Very amateur VB user, need help!

I need to write VB code to concatenate the data in 100 or more cells into a
single string. This is easy for a small number of cells:

ActiveCell.Offset(0, 0).FormulaR1C1 = _
ActiveCell.Offset(0, -1) & "," & ActiveCell.Offset(0, -2) etc.

But how do I do this without needing to type the "ActiveCell.Offset" 100
times? Is there any way to included a for/next loop within the concatenation?

Thanks!
/LJ
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default VB code to concatenate 100+ cells

Hi,


Dim myString as string

myString=""

For r=1 to 100
myString=MyString & cells(r,1) <=== Rows 1 to 100 of column A
next r


"LJones" wrote:

Hello,

Very amateur VB user, need help!

I need to write VB code to concatenate the data in 100 or more cells into a
single string. This is easy for a small number of cells:

ActiveCell.Offset(0, 0).FormulaR1C1 = _
ActiveCell.Offset(0, -1) & "," & ActiveCell.Offset(0, -2) etc.

But how do I do this without needing to type the "ActiveCell.Offset" 100
times? Is there any way to included a for/next loop within the concatenation?

Thanks!
/LJ

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default VB code to concatenate 100+ cells

Soory ... forgot about comma:

Dim myString as string

myString=""

For r=1 to 100
myString=MyString & cells(r,1) & "," <=== Rows 1 to 100 of column A
next r

myString=left(myString,len(mystring)-1)


"Toppers" wrote:

Hi,


Dim myString as string

myString=""

For r=1 to 100
myString=MyString & cells(r,1) <=== Rows 1 to 100 of column A
next r


"LJones" wrote:

Hello,

Very amateur VB user, need help!

I need to write VB code to concatenate the data in 100 or more cells into a
single string. This is easy for a small number of cells:

ActiveCell.Offset(0, 0).FormulaR1C1 = _
ActiveCell.Offset(0, -1) & "," & ActiveCell.Offset(0, -2) etc.

But how do I do this without needing to type the "ActiveCell.Offset" 100
times? Is there any way to included a for/next loop within the concatenation?

Thanks!
/LJ

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VB code to concatenate 100+ cells

Perfect! Thx again,
LJ

"Toppers" wrote:

Soory ... forgot about comma:

Dim myString as string

myString=""

For r=1 to 100
myString=MyString & cells(r,1) & "," <=== Rows 1 to 100 of column A
next r

myString=left(myString,len(mystring)-1)


"Toppers" wrote:

Hi,


Dim myString as string

myString=""

For r=1 to 100
myString=MyString & cells(r,1) <=== Rows 1 to 100 of column A
next r


"LJones" wrote:

Hello,

Very amateur VB user, need help!

I need to write VB code to concatenate the data in 100 or more cells into a
single string. This is easy for a small number of cells:

ActiveCell.Offset(0, 0).FormulaR1C1 = _
ActiveCell.Offset(0, -1) & "," & ActiveCell.Offset(0, -2) etc.

But how do I do this without needing to type the "ActiveCell.Offset" 100
times? Is there any way to included a for/next loop within the concatenation?

Thanks!
/LJ

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
Concatenate 4 cells Dgwood90 Excel Worksheet Functions 2 January 25th 10 04:14 AM
Concatenate Cells peterh Excel Worksheet Functions 5 December 16th 09 07:05 AM
Concatenate cells Snakeoids Excel Discussion (Misc queries) 6 July 28th 06 01:46 PM
post code & suburb concatenate varun Excel Discussion (Misc queries) 3 December 14th 05 09:18 AM
how do I UN-concatenate cells julia Excel Discussion (Misc queries) 2 January 5th 05 07:45 PM


All times are GMT +1. The time now is 06:51 PM.

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

About Us

"It's about Microsoft Excel"