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 / New Users / December 2007

Tip: Looking for answers? Try searching our database.

A how to, just can't find the answer anywhere! Please help me!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
UKDeluded - 04 Dec 2007 13:06 GMT
Okat, a spreadsheet with two tabs. Let's say tab one has | UID | DOB | NOSE
SIZE | (for example), tab 2 has |UID| No of Ears | Nose hair |

I would like to take duplicates where UID is the same out of tabs 1 and 2
and put into a new tab with | UID | DOB | No of ears | Nose hair | so third
tab has all people from tab one and two which exist in both and a cross
section of information from tab 1 and 2.

Have I confused anyone?!?

Thank you all because you're bound to be much cleverer than I is.
Bob Phillips - 04 Dec 2007 14:41 GMT
You should be abole to adapt this

Public Sub ProcessData()
Const COL_TAB1_UID As String = "A"
Const COL_TAB1_DOB As String = "B"
Const COL_TAB2_UID As String = "F"
Const COL_TAB2_EARS As String = "I"
Const COL_RESULTS_UID As String = "A"
Const COL_RESULTS_DOB As String = "B"
Const COL_RESULTS_EARS As String = "C"
Dim i As Long
Dim LastRow As Long
Dim NextRow As Long
Dim cell As Range
Dim sh As Worksheet
Dim newSheet As Worksheet

   On Error Resume Next
       Application.DisplayAlerts = False
       Worksheets("Results").Delete
       Application.DisplayAlerts = True
   On Error GoTo 0
   Set newSheet = Worksheets.Add
   newSheet.Name = "Results"
   Set sh = Worksheets("Tab 2")
   With Worksheets("Tab 1")

       LastRow = .Cells(.Rows.Count, COL_TAB1_UID).End(xlUp).Row
       newSheet.Cells(1, COL_RESULTS_UID).Value = "UID"
       newSheet.Cells(1, COL_RESULTS_DOB).Value = "DoB"
       newSheet.Cells(1, COL_RESULTS_EARS).Value = "No. of Ears"
       NextRow = 1
       For i = 2 To LastRow

           Set cell = Nothing
           Set cell = sh.Cells(1, COL_TAB2_UID).EntireColumn.Find(.Cells(i,
COL_TAB1_UID).Value)
           If Not cell Is Nothing Then

               NextRow = NextRow + 1
               newSheet.Cells(NextRow, COL_RESULTS_UID).Value = .Cells(i,
COL_TAB1_UID).Value
               newSheet.Cells(NextRow, COL_RESULTS_DOB).Value = .Cells(i,
COL_TAB1_DOB).Value
               newSheet.Cells(NextRow, COL_RESULTS_EARS).Value =
sh.Cells(cell.Row, COL_TAB2_EARS).Value
           End If
       Next i

   End With

End Sub

Signature

HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Okat, a spreadsheet with two tabs. Let's say tab one has | UID | DOB |
> NOSE
[quoted text clipped - 9 lines]
>
> Thank you all because you're bound to be much cleverer than I is.
 
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.