+ Reply to Thread
Results 1 to 3 of 3

Vlookup On Visible Cells Only

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-18-2010
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    546

    Vlookup On Visible Cells Only

    I am filtering a worksheet then using VLOOKUP() to return values. Problem I have is that the VLookup() is ignoring the filter condition. How should this formula be changed to only search visible (filtered) cells?

    Set lookupRange = Sheets("LooksIt").Range("$A:$C")
    Sheets("LooksIt").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A:$C").AutoFilter Field:=2, Criteria1:="<>"
    showData.Cells(i, "P").Value = Application.VLookup(showData.Cells(i, "A").Value, lookupRange, 3, False

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Vlookup On Visible Cells Only

    Instead of VLookup, use the .Find method with the argument LookIn:=xlValues. That method\argument searches only visible cells.

        Dim Found As Range
        
        With Sheets("LooksIt")
        
            .Range("$A:$C").AutoFilter Field:=2, Criteria1:="<>"
            
            Set Found = .Range("A:A").Find(What:=showData.Cells(i, "A").Value, _
                                           LookIn:=xlValues, _
                                           LookAt:=xlWhole, _
                                           SearchOrder:=xlByRows, _
                                           SearchDirection:=xlNext, _
                                           MatchCase:=False)
            If Not Found Is Nothing Then
                showData.Cells(i, "P").Value = Found.Offset(, 2).Value
            Else
                MsgBox showData.Cells(i, "A").Value, , "No Match Found"
            End If
            
        End With
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    06-18-2010
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    546

    Re: Vlookup On Visible Cells Only

    That got it, thank you!

+ 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. [SOLVED] VLOOKUP only on visible cells
    By bibu in forum Excel General
    Replies: 2
    Last Post: 03-21-2015, 04:18 PM
  2. Vlookup on Visible cells after filter particular value
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-07-2014, 10:29 AM
  3. how to copy from visible cells to visible cells
    By guhaseelan in forum Excel General
    Replies: 2
    Last Post: 04-16-2014, 09:32 AM
  4. [SOLVED] Copy/Pasting Values from visible cells (using autofilter) to visible cells
    By evakotsi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2012, 07:49 AM
  5. [SOLVED] changing a current mod (count unique visible cells ->count unique visible cells criteria
    By liranbo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-30-2012, 03:58 AM
  6. Replacing visible cells with vlookup formula
    By Mansoor_naz2002 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-01-2010, 12:48 PM
  7. Copy Visible cells and paste values only to visible target cells
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2010, 04:09 AM

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