Matching two worksheet?

S

SF

Hi

I have two excel worksheets both worksheet contain one column that have same
data. I want to bring extra column from worksheet # 2 to put side by side in
worksheet # 1 base on first column (that have same data eg Commune Name) Is
there a way to match or merge these two worksheet?

SF
 
G

Guest

I place the item found on sheet 2 but weren't on Sheet 1 and the end of the
list. Try the code.

Sub combinesheets()

With Sheets("Sheet1")
LastRowSh1 = _
.Cells(Rows.Count, "A").End(xlUp).Row
Set Sh1Range = .Range(.Cells(1, "A"), _
.Cells(LastRowSh1, "A"))
End With
With Sheets("Sheet2")
LastRowSh2 = _
.Cells(Rows.Count, "A").End(xlUp).Row
Set Sh2Range = .Range(.Cells(1, "A"), _
.Cells(LastRowSh1, "A"))

For Each cell In Sh2Range
Set c = Sh1Range.Find(what:=cell, _
LookIn:=xlValues)
If Not c Is Nothing Then
c.Offset(0, 1) = cell
Else
Sheets("Sheet1"). _
Cells(LastRowSh1 + 1, "B") = _
cell
LastRowSh1 = LastRowSh1 + 1
End If

Next cell
End With


End Sub
 

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