Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Concatenate a Range of Cells

Leith,

I am using a combination of your and JMB's suggestions. This does what I
need.

Thanks...

---

Public Sub JoinCells()

Dim row_num As Range
Dim cell As Range
Dim result As String

With Selection
For Each row_num In .Rows
For Each cell In row_num.Cells
result = result & cell.Value & " "
Next cell
If row_num.Row < .Rows(.Rows.Count).Row Then result = result & Chr(10)
Next row_num
End With

With Cells(Selection.Row, Selection.Column + Selection.Columns.Count)
.Value = result
.WrapText = True
End With

End Sub


"Leith Ross" wrote
in message ...

Hello Bob,

Here is a different version take puts the text in rows.

Public Sub ConcatenateRows()

Dim FirstColumn
Dim ColumnCount
Dim FirstRow
Dim LastRow
Dim N
Dim NewCell As Range

With Selection
FirstColumn = .Item(1).Column
ColumnCount = .Columns.Count
FirstRow = .Item(1).Row
LastRow = .Rows.Count + FirstRow - 1
End With

Set NewCell = ActiveSheet.Cells(LastRow + 1, FirstColumn)

For Each Cell In Selection
N = N + 1
NewCell = NewCell & " " & Cell.Value
If N = ColumnCount Then
NewCell = NewCell & vbLf
N = 0
End If
Next Cell

End Sub

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=505582



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
Function to concatenate cells in a range Leporello Excel Worksheet Functions 3 May 12th 23 07:42 PM
concatenate with a varying range of cells Riversage Excel Worksheet Functions 0 January 29th 07 07:43 PM
concatenate cells by a given range Twan Kennis Excel Worksheet Functions 4 July 1st 06 12:54 AM
How do I concatenate two currency cells to show a price range? nevermore627 Excel Worksheet Functions 5 June 30th 06 05:03 PM
How to concatenate adjacent cells in a range without using &? Ark Excel Worksheet Functions 4 October 16th 05 06:38 PM


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

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"