View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default combining rows in an excel file

Try some code like the following. Change the lines marked with <<<< to
the appropriate values. StartCell is the first cell of the original
input data. Destination is the first cell of the combined rows.
NumColumns is the number of columns from the input data to copy to the
output data. The code will loop from StartCell downward until a blank
cell is encountered.


Sub AAA()
Dim StartCell As Range
Dim Destination As Range
Dim NumColumns As Long

NumColumns = 3 '<<< CHANGE
Set StartCell = Worksheets("Sheet2").Range("A1") '<<<< CHANGE
Set Destination = Worksheets("Sheet3").Range("A1") '<<<< CHANGE
Do Until StartCell.Value = vbNullString
StartCell.Resize(1, NumColumns).Copy _
Destination:=Destination
StartCell(2, 1).Resize(1, NumColumns).Copy _
Destination:=Destination(1, NumColumns + 1)
Set StartCell = StartCell(3, 1)
Set Destination = Destination(2, 1)
Loop
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Tue, 17 Feb 2009 12:44:01 -0800, kbonner@wabt
wrote:

I have a report that is downloaded and the customer information is in 2 rows.
I need this combined into one row so that it can be sorted.
Please help