Combining / Merging several rows - but want to keep formatting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Help - please !
I have exported out of a database, saved as a TXT file, and brought into
Excel a large set of overview text (approx. 7000 records). Unfortunately,
the overview text has separated into rows rather than stay together as one
large overview text.

The text can be 2-25 rows and is separated from the next by a blank row.
Is there a way to capture the text from the next line, ALT_Enter it into the
first line so it appends and keep doing this for each subsequent row until
the blank row is reached (indicating a new overview is about to follow).

I've tried merging, but it makes one long row and loses formatting. With
bullet points in the overview, among other items, it makes it look like a
huge mess.

Thank you in advance!
Gene
 
So you have one giant column (A) of data? Nothing anywhere else???

If yes:

Option Explicit
Sub testme()
Dim myCell As Range
Dim myRng As Range
Dim myArea As Range
Dim wks As Worksheet
Dim myStr As String

Set wks = Worksheets("sheet1")

With wks
Set myRng = Nothing
On Error Resume Next
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp)) _
.Cells.SpecialCells(xlCellTypeConstants)
On Error GoTo 0
End With

If myRng Is Nothing Then
MsgBox "No constants in column A!"
Exit Sub
End If

For Each myArea In myRng.Areas
myStr = ""
For Each myCell In myArea.Cells
myStr = myStr & vbLf & myCell.Value
Next myCell
If myStr <> "" Then
myStr = Mid(myStr, 2)
End If
myArea.Cells(1).Offset(0, 1).Value = myStr
Next myArea

'positive that it worked???
'wks.Columns(1).delete
'or delete column A manually

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top