Merging 2 sheets.

B

Bruce Bowler

I'll be the first to admit that this is a simple problem, but I can't seem
to get beyond the brain-fart I'm having today...

I have 2 sheets, call them (most imaginatively) sheet1 and sheet2.

Column A in sheet1 is a series of unique numbers.

Column E in sheet2 is a series of numbers (non-unique).

Both sheets are sorted on those columns, in the event it makes life easier.

All of the numbers in sheet1 also exist in sheet2 but the reverse is not
true.

Each time a number appears in sheet2/colE that matches a number in sheet1/
colA, I want to copy the values in sheet1/colB thru colE into sheet2/cOlG
thru colJ.

Clear as mud?

Thanks!
Bruce
 
J

Jim Cone

Something like this...
'---
Sub BreadcrumbWaggles()
'Jim Cone - Portland, Oregon - October 2011
Dim rngColumnOne As Range
Dim rngColumnTwo As Range
Dim rngFound As Range
Dim rCell As Range

Set rngColumnOne = Worksheets(1).Range("A1:A20").Cells
Set rngColumnTwo = Worksheets(2).Range("E1:E20").Cells

For Each rCell In rngColumnTwo
On Error Resume Next
Set rngFound = rngColumnOne.Cells(Application.WorksheetFunction.Match(rCell, rngColumnOne, 0),
1)
On Error GoTo 0
If Not rngFound Is Nothing Then
rCell.Resize(1, 4).Offset(0, 2).Value = rngFound.Resize(1, 4).Offset(0, 1).Value
Set rngFound = Nothing
End If
Next
End Sub
'---
Jim Cone
Portland, Oregon USA
http://www.contextures.com/excel-sort-addin.html
(editorial review of special sort excel add-in (30 ways to sort)




"Bruce Bowler" <[email protected]>
wrote in message
news:[email protected]...
 

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