+ Reply to Thread
Results 1 to 5 of 5

VBA to find instead of Vlookup

  1. #1
    Registered User
    Join Date
    02-19-2011
    Location
    Cairo
    MS-Off Ver
    Excel 2010
    Posts
    60

    Lightbulb VBA to find instead of Vlookup

    Hello Experts,

    I have two sheets with two columns in each sheet,
    column (A) contain customer name
    Column (B) contain the region name



    Now, i would like to create a macro to copy the values from sheet1 column (A) and look after it in sheet2 column (A) if found in a string to copy the next value from Sheet2 column (B) which is region name to sheet 1 column (B),
    by the way i tried Vlookup but when the customer name is not exactly the same in sheets 1&2 it doesn't work...

    example :
    customer name in Sheet(1) cell A7 = [ADB] .... i want to get the region name in column B...
    while in Sheet(2) the same customer name is = [ADB - African Development Bank]
    when i put a standard Vlookup it will not find it - so i need to do FIND instead of Vlookup ...
    is it possible

    here is the code of the recorded macro :

    Please Login or Register  to view this content.
    Many thanks for your support,
    Wellous,

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: VBA to find instead of Vlookup

    You can use a * as a wildcard with VLOOKUP so it will perform a partial match.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    02-19-2011
    Location
    Cairo
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: VBA to find instead of Vlookup

    Thanks, i used =VLOOKUP(LEFT(A7,3)&"*",Sheet2!$B$2:$C$1953,2,FALSE) but it's not working all the time,
    i also don't know how it use * before the string?

    thanks again

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: VBA to find instead of Vlookup

    If you want to match data containing say "ABC" anywhere in it, you would use:
    =VLOOKUP("*ABC*",Sheet2!$B$2:$C$1953,2,FALSE)

    Without data I can't tell you why it only works some of the time other than to say that your lookup table doesn't contain a cell in the first column that begins with the first three characters of your lookup cell.

  5. #5
    Registered User
    Join Date
    02-19-2011
    Location
    Cairo
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: VBA to find instead of Vlookup

    Thanks, it's sloving the problem

+ 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: 0
    Last Post: 12-26-2013, 01:12 PM
  2. Replies: 1
    Last Post: 12-17-2012, 08:00 PM
  3. Using VLOOKUP to find multiple occurrences and find the Total quantity
    By susanpa in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-30-2009, 09:54 AM
  4. Replies: 4
    Last Post: 10-18-2006, 12:25 PM
  5. [SOLVED] 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