ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is it possible with a macro?? (https://www.excelbanter.com/excel-programming/417163-possible-macro.html)

cbart

Is it possible with a macro??
 
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


Per Jessen

Is it possible with a macro??
 
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

"cbart" skrev i meddelelsen
...
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



cbart

Is it possible with a macro??
 
Thank you so much!!!

"Per Jessen" wrote:

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

"cbart" skrev i meddelelsen
...
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





All times are GMT +1. The time now is 02:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com