Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Consolidate text

Hi

I have a large spreadsheet that I need to trawl though consolidating column
cells. the process I haver been using is to select the cells and copy them
into word, convert them from table to text, copy the result, select the top
cell of the selection in excell and paste the result. This is a huge job
which could be speeded up hugely by a wee macro. I have used macros in MS
word and Access but the excel syntax is not familiar at all and I could
really do with some help.

In essence I need a macro that will take the contents of a selection (this
will be a number of cells containing text in a column) and join all of the
contents with a paragraph between. the resulting string is deposited in the
top cell and the remaining cells cleared of contents

I will have a go from examples I find but if someone has some code thay
could throw at me (or even some hints it would be well appreciated

Cheers
IanB
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Consolidate text

Here is some code (modified from code designed to make CSV strings)...

Private Const m_cMaxConcatenateRows As Integer = 1000

Private Sub MakeCSV()
Dim wksCurrent As Worksheet
Dim rngCurrent As Range
Dim rngToSearch As Range
Dim rngToPaste As Range
Dim intCounter As Integer
Dim wksPasteTo As Worksheet

Application.ScreenUpdating = False
intCounter = 0
Set wksCurrent = ActiveSheet
Set rngToSearch = Intersect(Selection, wksCurrent.UsedRange)
Set rngToPaste = Selection.Cells(1)

rngToPaste.NumberFormat = "@"

For Each rngCurrent In rngToSearch
If Trim(rngCurrent.Value) < "" Then
intCounter = intCounter + 1
If intCounter m_cMaxConcatenateRows Then
intCounter = 0
Set rngToPaste = rngToPaste.Offset(1, 0)
rngToPaste.NumberFormat = "@"
rngToPaste.Value = rngCurrent.Value
Else
If intCounter = 1 Then
rngToPaste.Value = rngCurrent.Value
Else
rngToPaste.Value = rngToPaste.Value & vbLf &
rngCurrent.Value
rngCurrent.ClearContents
End If
End If
End If
Next rngCurrent
Application.ScreenUpdating = True
End Sub

--
HTH...

Jim Thomlinson


"Ianb" wrote:

Hi

I have a large spreadsheet that I need to trawl though consolidating column
cells. the process I haver been using is to select the cells and copy them
into word, convert them from table to text, copy the result, select the top
cell of the selection in excell and paste the result. This is a huge job
which could be speeded up hugely by a wee macro. I have used macros in MS
word and Access but the excel syntax is not familiar at all and I could
really do with some help.

In essence I need a macro that will take the contents of a selection (this
will be a number of cells containing text in a column) and join all of the
contents with a paragraph between. the resulting string is deposited in the
top cell and the remaining cells cleared of contents

I will have a go from examples I find but if someone has some code thay
could throw at me (or even some hints it would be well appreciated

Cheers
IanB

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Consolidate text

Thanks Jim

I have to say that is amazing service - just the solution and in just 10
minutes. It will save me a day al least - although it will probably take a
half a day to figure how it works :)
Good Kama on you


Ian


"Jim Thomlinson" wrote:

Here is some code (modified from code designed to make CSV strings)...

Private Const m_cMaxConcatenateRows As Integer = 1000

Private Sub MakeCSV()
Dim wksCurrent As Worksheet
Dim rngCurrent As Range
Dim rngToSearch As Range
Dim rngToPaste As Range
Dim intCounter As Integer
Dim wksPasteTo As Worksheet

Application.ScreenUpdating = False
intCounter = 0
Set wksCurrent = ActiveSheet
Set rngToSearch = Intersect(Selection, wksCurrent.UsedRange)
Set rngToPaste = Selection.Cells(1)

rngToPaste.NumberFormat = "@"

For Each rngCurrent In rngToSearch
If Trim(rngCurrent.Value) < "" Then
intCounter = intCounter + 1
If intCounter m_cMaxConcatenateRows Then
intCounter = 0
Set rngToPaste = rngToPaste.Offset(1, 0)
rngToPaste.NumberFormat = "@"
rngToPaste.Value = rngCurrent.Value
Else
If intCounter = 1 Then
rngToPaste.Value = rngCurrent.Value
Else
rngToPaste.Value = rngToPaste.Value & vbLf &
rngCurrent.Value
rngCurrent.ClearContents
End If
End If
End If
Next rngCurrent
Application.ScreenUpdating = True
End Sub

--
HTH...

Jim Thomlinson


"Ianb" wrote:

Hi

I have a large spreadsheet that I need to trawl though consolidating column
cells. the process I haver been using is to select the cells and copy them
into word, convert them from table to text, copy the result, select the top
cell of the selection in excell and paste the result. This is a huge job
which could be speeded up hugely by a wee macro. I have used macros in MS
word and Access but the excel syntax is not familiar at all and I could
really do with some help.

In essence I need a macro that will take the contents of a selection (this
will be a number of cells containing text in a column) and join all of the
contents with a paragraph between. the resulting string is deposited in the
top cell and the remaining cells cleared of contents

I will have a go from examples I find but if someone has some code thay
could throw at me (or even some hints it would be well appreciated

Cheers
IanB

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
Consolidate Data & Text Enrique Excel Discussion (Misc queries) 5 April 10th 07 12:16 PM
Can't consolidate non-data (ie text) cells from worksheets Tim80 Excel Worksheet Functions 2 June 19th 06 02:59 PM
How do you consolidate tables contianing text? samenvoegen van sheets Excel Worksheet Functions 0 February 22nd 06 10:04 AM
Consolidate text EXCEL101 Excel Discussion (Misc queries) 2 February 18th 06 03:59 PM
How do I consolidate files comprised of only text? joconnorrealty New Users to Excel 1 April 12th 05 12:21 AM


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