Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Matching two worksheet?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SF - 14 Sep 2007 04:20 GMT
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 - 14 Sep 2007 11:08 GMT
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

> Hi
>
[quoted text clipped - 4 lines]
>
> SF
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.