+ Reply to Thread
Results 1 to 7 of 7

Find row in another sheet with multiple criteria not looping

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-01-2013
    Location
    Oslo
    MS-Off Ver
    Excel 2010
    Posts
    163

    Find row in another sheet with multiple criteria not looping

    Hi,

    I have been looking for a code that can search a row in sheet2 with 2 critiria specified in sheet1 and return row number. I need also to put "if clause" as there might be possibility that such a search is not existed and that i can assign another code for not found record. I cannot use looping method because my data can be up to 10000 records.

    Sheet1
    A1: Name
    B1: Surname

    Sheet2
    ColumnA: Name
    ColumnB: Surname
    ColumnC: Address
    ColumnD: Salary

    Thanks for help

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Find row in another sheet with multiple criteria not looping

    Hi,
    Looping throw the 10k cells isn't good idea, but if you put data from Sheet2 into array - it will decrease time of searching significantly.
    For search by two criteria you could use something like:
    Array(i) = Criteria1 AND Array(i+1) = Criteria2

  3. #3
    Forum Contributor
    Join Date
    02-01-2013
    Location
    Oslo
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Find row in another sheet with multiple criteria not looping

    Hi Kasan,

    Thank you for your reply.
    I'm not an expert in VBA. Would you please explain more in detail? How can i set array for sheet 2? and how to get row number for the code you gave ?

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,653

    Re: Find row in another sheet with multiple criteria not looping

    No loop.
    Sub test()
        Dim x
        With Sheets("sheet1")
            x = Filter(.[transpose(if((sheet2!a1:a20000=a1)*(sheet2!b1:b20000=b1),row(1:20000)))], False, 0)
        End With
        MsgBox IIf(UBound(x) > -1, "Found in" & vbLf & Join(x, vbLf), "No match")
    End Sub

  5. #5
    Forum Contributor
    Join Date
    02-01-2013
    Location
    Oslo
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Find row in another sheet with multiple criteria not looping

    Hi Jindon,

    Thank you for your reply. As my sheet has been named, i got debug message in this line.
    Would you please help ?
    x = Filter(.[transpose(if((Sheets("Requirement Status Results")!a1:a20000=D6)*(Sheets("Requirement Status Results")!g1:g20000="VT"),row(1:20000)))], False, 0)

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,653

    Re: Find row in another sheet with multiple criteria not looping

    Try change to
    x = Filter(.[transpose(if(('Requirement Status Results'!a1:a20000=D6)*('Requirement Status Results'!g1:g20000="VT"),row(1:20000)))], False, 0)

  7. #7
    Forum Contributor
    Join Date
    02-01-2013
    Location
    Oslo
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Find row in another sheet with multiple criteria not looping

    wow Amazing

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 8
    Last Post: 05-08-2016, 12:48 AM
  2. Replies: 2
    Last Post: 01-23-2016, 01:16 PM
  3. Replies: 2
    Last Post: 05-26-2015, 07:29 PM
  4. Need help looping through multiple sheets to conditionally format the same range/sheet
    By xcelnovice101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2014, 10:54 AM
  5. Looping to find multiple maximums within one column
    By phoenix1856 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-05-2013, 01:12 PM
  6. Looping A Copy Sheet for Multiple Workbooks
    By mburke05 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2012, 09:00 AM
  7. Replies: 2
    Last Post: 05-10-2012, 10:38 AM

Tags for this Thread

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