View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default SIMPLE CONCATENATE FUNCTION

We can shorten your macro up by removing the loop...

Sub MakeSentence()
Dim MC As Long
MC = 1 'Column A
Cells(1, MC + 1).Value = Join(WorksheetFunction.Transpose( _
Range(Cells(1, MC), Cells( _
Rows.Count, MC).End(xlUp))), " ")
Columns(MC + 1).Columns.AutoFit
End Sub

--
Rick (MVP - Excel)


"Don Guillett" wrote in message
...
Macro solution

Option Explicit
Sub makesentence()
Dim mc As Long
Dim i As Long
Dim ms As String
mc = 1 'col A
For i = 1 To Cells(Rows.Count, mc).End(xlUp).Row
ms = ms & Cells(i, mc) & " "
Next i
'MsgBox ms
Cells(1, mc + 1) = ms
Columns(mc + 1).Columns.AutoFit
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rebecca" wrote in message
...
I apologize for asking such an incredibly newbie question, but I simply
can't
get this to work, despite reading the help files and searching this
forum. I
am using Windows 7 and newly purchased Excel 2007.

I have a column A with the following words (this is a simple, made-up
example): in

A1 The
A2 book
A3 is
A4 on
A5 the
A6 shelf.

I want to CONCATENATE them into one sentence in one cell. I can get
CONCATENATE to work in one row of cells in two or more columns, but I
can't
get it to work in several rows of cells in the same column. Could you
please
explain in detail how this can be done? Thanks.