Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default copying duplicate entries

One way:

Option Explicit
Sub testme()

Application.screenupdating = false

Dim FirstRow As Long
Dim LastRow As Long
Dim oCol As Long
Dim oRow As Long
Dim iRow As Long

Dim curWks As Worksheet
Dim newWks As Worksheet

Set curWks = Worksheets("sheet1")
Set newWks = Worksheets.Add

oRow = 1
With curWks

FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

newWks.Range("a1").Value = .Cells(FirstRow, "A").Value
newWks.Range("b1").Value = .Cells(FirstRow, "B").Value

oCol = 3
For iRow = FirstRow + 1 To LastRow
If .Cells(iRow, "A").Value = .Cells(iRow - 1, "A").Value Then
newWks.Cells(oRow, oCol).Value = .Cells(iRow, "B").Value
oCol = oCol + 1
If oCol .Columns.Count Then
MsgBox "Too many entries at row: " & iRow
Exit Sub
End If
Else
oRow = oRow + 1
newWks.Cells(oRow, "A").Value = .Cells(iRow, "A").Value
newWks.Cells(oRow, "B").Value = .Cells(iRow, "B").Value
oCol = 3
End If
Next iRow
End With

Application.screenupdating = true

End Sub


walter wrote:

I have the following list:

abc 123
abc 456
abc 789
xyz 345
xyz 987

What i want to end up with is this:

abc 123 456 789
xyz 345 987

How can this be done???

T.i.a.

Walter.


--

Dave Peterson

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
Duplicate entries Radiorick Excel Worksheet Functions 5 March 23rd 19 12:39 PM
Duplicate entries nackgr Excel Discussion (Misc queries) 1 January 7th 11 01:15 PM
Duplicate entries Brenda Excel Discussion (Misc queries) 2 February 16th 07 07:17 PM
Duplicate Entries Phxlatinoboi® Excel Discussion (Misc queries) 2 August 24th 06 01:17 AM
Duplicate entries DMC Excel Worksheet Functions 1 December 19th 04 08:45 PM


All times are GMT +1. The time now is 10:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"