+ Reply to Thread
Results 1 to 4 of 4

VBA Vlookup Function

  1. #1
    Forum Contributor
    Join Date
    07-17-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    461

    VBA Vlookup Function

    Hi All,

    I have two columns phone number and fax number. Here I need to find the whichever phone number is there in fax number. Generally I used to do vlookup and find them. Is this same thing can we do in vba? The number of rows i used in this example are 39 rows. It may randomly vary. Please find the attached file.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,202

    Re: VBA Vlookup Function

    Why not

    =IFERROR(VLOOKUP($C2,$B$2:$B$40,1,0),"")

  3. #3
    Forum Contributor
    Join Date
    07-17-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    461

    Re: VBA Vlookup Function

    If my records increase. Do this work? Example if i have 1000 records?

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: VBA Vlookup Function

    1000 is nothing. Unless you have somewhere in excess of 25k records. You are fine with simple VLookup.
    If speed becomes issue, use double approximate VLOOKUP to take advantage of binary search.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Note that this requires "Phone Number" column to be sorted ascending (smallest to largest in sort option).
    FYI - This will be faster than VBA method on sorted data.
    You can read up more in detail about double approximate VLOOKUP in link below.
    https://fastexcel.wordpress.com/2012...han-1-vlookup/

    Also, I'd either put data range into Excel Table and use structured reference or use Dynamic Named range.
    So that you don't have to adjust lookup range when data range changes.

    PhNum (Named range)
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    See attached.
    Attached Files Attached Files
    Last edited by CK76; 05-23-2018 at 04:24 PM. Reason: Added FYI
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

+ 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] Trying to Multiply the result of an IF function combined with a VLOOKUP function
    By ucca in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-28-2018, 02:32 AM
  2. Formula Structure Error When Combining IF Function with VLOOKUP Function
    By EverClever in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-16-2017, 03:11 PM
  3. [SOLVED] VLOOKUP formula or VLOOKUP worksheet.function
    By Crispy85 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-09-2017, 09:40 AM
  4. Replies: 2
    Last Post: 01-15-2014, 11:40 PM
  5. Worksheet function Vlookup and VLOOKUP return different results
    By zandero in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-08-2010, 08:24 AM
  6. Replies: 1
    Last Post: 12-02-2005, 09:35 AM
  7. vlookup function-Can vlookup command find the data from the 5 sheets.
    By Rishab shah in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

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