Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 02-16-2017, 08:11 AM
NoSparks NoSparks is offline Comparing between 2 worksheets and retreiving data if a match Windows 7 64bit Comparing between 2 worksheets and retreiving data if a match Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

based on post #1, and assuming the first name, initial and last name combination only appears once on the 'List' sheet, you could perhaps use the range.find and .findnext methods based on the last name.
Code:
Sub Fugman_02_16_2017()

Dim Lname As String, Initial As String, Fname As String
Dim fndLastName As Range, firstAddress As String
    
With Sheets("Input Data")
    Lname = .Range("G1").Value
    Initial = .Range("F1").Value
    Fname = .Range("E1").Value
End With

With Sheets("List").Range("G:G")
    Set fndLastName = .Find(What:=Lname, After:=.Cells(.Cells.Count), _
                        LookIn:=xlValues, LookAt:=xlWhole, _
                        SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                        MatchCase:=False)
    
    If Not fndLastName Is Nothing Then
        firstAddress = fndLastName.Address
        Do
            If fndLastName.Offset(0, -2).Value = Fname And fndLastName.Offset(0, -1).Value = Initial Then
                fndLastName.Offset(0, 1).Resize(1, 19).Copy Sheets("Input Data").Range("H1")
                Exit Do
            End If
            Set fndLastName = .FindNext(fndLastName)
        Loop While Not fndLastName Is Nothing And fndLastName.Address <> firstAddress
    End If
End With

End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Index Match Function across different worksheets shay_mt Excel 2 04-27-2015 06:04 AM
Comparing between 2 worksheets and retreiving data if a match comparing data sjp1966 Excel 6 07-23-2014 11:43 AM
Comparing two excel worksheets SaneMan Excel 1 06-27-2012 07:52 PM
Comparing Data - MS Excel ramadevidokkuud Excel 1 05-19-2011 05:52 AM
Comparing between 2 worksheets and retreiving data if a match Comparing Data leroytrolley Excel 1 08-09-2008 08:34 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft