Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10
Default how to select and append a column in VB and excel tia sal2

Greetings All

I'm trying to select a column of cells and append all there contents to
one cell. Does anyone have some example vb.script that does this in excel

Example
select excel column A1 to A70
Append all values in A1 to A70 in Cell C4 with the phrase "code" after
each value. so C4 would look like "tre345 code tre346 code tre347 code"


Please reply to newsgroups as email address isn't real
tia sal2
  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 703
Default how to select and append a column in VB and excel tia sal2

Hi

Try this:

Public Function AppendCode(TargetRange As Range)
For Each cell In TargetRange
If myStr = "" Then
myStr = cell.Value & " code"
Else
myStr = myStr & " " & cell.Value & " code"
End If
Next
AppendCode = myStr
End Function


In C4 enter the formula:

=AppendCode(A1:A70)

Hopes this helps

---
Per

On 27 Jan., 19:06, sal2 wrote:
Greetings All

I'm trying to select a column of cells and append all there contents to
one cell. *Does anyone have some example vb.script that does this in excel

Example
select excel column A1 to A70
Append all values in A1 to A70 in Cell C4 with the phrase "code" after
each value. so C4 would look like "tre345 code tre346 code tre347 code"

Please reply to newsgroups as email address isn't real
tia sal2


  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default how to select and append a column in VB and excel tia sal2

Hi,

Put this in a general module

Function AddSuffix(Rng As Range, suffix As String) As String
For Each c In Rng
If c.Value < "" Then
MyString = MyString & c.Value & " " & suffix & " "
End If '
Next
AddSuffix = MyString
End Function


Call with this in C4

=addsuffix(A1:A70,"Code")

Mike

"sal2" wrote:

Greetings All

I'm trying to select a column of cells and append all there contents to
one cell. Does anyone have some example vb.script that does this in excel

Example
select excel column A1 to A70
Append all values in A1 to A70 in Cell C4 with the phrase "code" after
each value. so C4 would look like "tre345 code tre346 code tre347 code"


Please reply to newsgroups as email address isn't real
tia sal2

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 to select and append a column in VB and excel tia sal2 sal2 Excel Discussion (Misc queries) 2 January 27th 09 06:29 PM
how to select and append a column in VB and excel tia sal2 sal2 Excel Worksheet Functions 2 January 27th 09 06:29 PM
append column data ACarella Excel Worksheet Functions 3 July 22nd 08 06:13 PM
How to concatenate a column into one cell? tia sal2 [email protected] Excel Discussion (Misc queries) 2 January 12th 07 09:50 PM
Append Columns to another column sean_f Excel Programming 0 April 18th 06 04:30 PM


All times are GMT +1. The time now is 10:09 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"