+ Reply to Thread
Results 1 to 2 of 2

convert, extract city using a list and lookup formula to vba

  1. #1
    Registered User
    Join Date
    03-10-2012
    Location
    toronto
    MS-Off Ver
    Excel 2010
    Posts
    1

    convert, extract city using a list and lookup formula to vba

    Hello,

    I've managed to use a formula that extracts the city from an address cell, using an exhaustive city list. Formula is below. I tried using worksheetfunction. to write vba to do the same, but failed. Does anyone have any advice on how to use vba to do what the formula below is doing.

    =LOOKUP(2^15,SEARCH(sheet2!$A$1:$A$765344,A1),sheet2!$A$1:$A$765344)

    "a1" is the address cell i'm extracting from, sheet2!... is the city list array, the whole formula is on sheet3.

    Thanks
    Terry
    Last edited by gentledragon; 05-08-2012 at 10:15 PM. Reason: more concise title

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: convert, extract city using a list and lookup formula to vba

    If you have a working formula, why not just use it? Even in VBA, you can simply enter that formula into the range of cells needed, then remove the formula, leaving the results behind. This macro will enter that formula in column D down to the bottom of the data in column A, then remove the formulas:


    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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