Is it possible with a macro??

C

cbart

I have data in six columns (A-F) an Excel spreadsheet. See the duplicate
number 82131400? I want to leave the first 82131400 line alone, but move the
data from second and third *400 rows onto the same row as the first *400
number but into columns (G-R). Possible with a macro? thanks.

82129735 8/31/2006 -120502 1-SO 8/30/2006 8/31/2006
82131400 8/31/2006 -121401 1-SO 8/31/2006 8/31/2006
82131400 LDR802- L/D 8/31/2006 8/31/2006
82131400 LDR901- L/D 8/31/2006 8/31/2006
82128158 8/31/2006 -313101 3-NO 8/29/2006 8/31/2006
 
P

Per Jessen

Hi

Look at this:

Sub test()
Dim StartCell As Range
Dim CopyCell As Range
Dim off As Long

Set StartCell = Range("A1") ' assuming no headers
Set CopyCell = StartCell.Offset(1, 1)

Do Until StartCell.Offset(1, 0) = ""
If StartCell.Offset(1, 0).Value = StartCell.Value Then
Range(CopyCell.Address, CopyCell.End(xlToRight).Address).Copy _
Destination:=StartCell.End(xlToRight).Offset(0, 1)
StartCell.Offset(1, 0).EntireRow.Delete
Set CopyCell = StartCell.Offset(1, 1)
Else
Set StartCell = StartCell.Offset(1, 0)
Set CopyCell = CopyCell.Offset(1, 0)
End If
Loop
End Sub

Regards,
Per
 
C

cbart

Thank you so much!!!

Per Jessen said:
Hi

Look at this:

Sub test()
Dim StartCell As Range
Dim CopyCell As Range
Dim off As Long

Set StartCell = Range("A1") ' assuming no headers
Set CopyCell = StartCell.Offset(1, 1)

Do Until StartCell.Offset(1, 0) = ""
If StartCell.Offset(1, 0).Value = StartCell.Value Then
Range(CopyCell.Address, CopyCell.End(xlToRight).Address).Copy _
Destination:=StartCell.End(xlToRight).Offset(0, 1)
StartCell.Offset(1, 0).EntireRow.Delete
Set CopyCell = StartCell.Offset(1, 1)
Else
Set StartCell = StartCell.Offset(1, 0)
Set CopyCell = CopyCell.Offset(1, 0)
End If
Loop
End Sub

Regards,
Per
 

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

Top