ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Matching two worksheet? (https://www.excelbanter.com/excel-programming/397455-matching-two-worksheet.html)

SF

Matching two worksheet?
 
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



joel

Matching two worksheet?
 
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


"SF" wrote:

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





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

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