+ Reply to Thread
Results 1 to 4 of 4

Lookup data from 2 worksheets and display yes or no

Hybrid View

  1. #1
    Registered User
    Join Date
    05-18-2009
    Location
    Blackpool
    MS-Off Ver
    Excel 2007
    Posts
    2

    Post Lookup data from 2 worksheets and display yes or no

    Hi, I very rarely use Excel and would appreciate some guidance...

    I have 2 lots of data within one workbook
    i) HR data containing Employee Number surname and Known as (actual employees)
    ii) NT Data containing the same info. (logon accounts)

    I would like to cross reference/search/vlookup the Employee Number from the 2 worksheets to see if the employees in the HR data has an NT logon account in the NT data worksheet - I would like it to return a YES or NO in a column within the HR Data worksheet dependant obviously if the data can be found or not.

    Then what I can do is filter the No's to double check the information to see if one needs creating.

    Please find attached a sample XLS document.

    Thanks for your time.
    Kind regards
    Attached Files Attached Files
    Last edited by TiSwAs; 05-18-2009 at 08:25 AM.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Lookup data from 2 worksheets and display yes or no

    Try with this code:
    Sub Macro1()
       Dim hrSh As Worksheet
       Dim nrSh As Worksheet
       
       Set hrSh = ThisWorkbook.Sheets("hr data")
       Set ntsh = ThisWorkbook.Sheets("nt data")
       
       lastrow = hrSh.Cells(Rows.Count, "a").End(xlUp).Row
       
       For r = 2 To lastrow
          myResult = Evaluate("isna(vlookup('" & hrSh.Name & "'!a" & r & ",'" _
                     & ntsh.Name & "'!a:a,1,false))")
          If myResult = True Then
             hrSh.Cells(r, "d") = "No"
          Else
             hrSh.Cells(r, "d") = "Yes"
          End If
       Next r
    End Sub
    Regards,
    Antonio

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Lookup data from 2 worksheets and display yes or no

    Or alternatively

    Public Sub NTCHECK()
    Sheets("HR Data").Select
    With Range(Cells(2, "A"), Cells(Rows.Count, "A").End(xlUp)).Offset(, 3)
        .FormulaR1C1 = "=IF(ISNA(MATCH(RC1,'NT Data'!C1,0)),""No"",""Yes"")"
        .Value = .Value
    End With
    End Sub
    If you want to do without VBA

    HR Data!D2: =IF(ISNA(MATCH(A2,'NT Data'!A:A,0)),"No","Yes")
    copied down

  4. #4
    Registered User
    Join Date
    05-18-2009
    Location
    Blackpool
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Lookup data from 2 worksheets and display yes or no

    Quote Originally Posted by DonkeyOte View Post
    If you want to do without VBA

    HR Data!D2: =IF(ISNA(MATCH(A2,'NT Data'!A:A,0)),"No","Yes")
    copied down
    Thank you both for the reply - i went with the none visual basic and it work great.

    thanks again and you can mark this one as solved.

    Kind Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1