+ Reply to Thread
Results 1 to 2 of 2

Storing a vba lookup in an array

  1. #1
    Registered User
    Join Date
    03-24-2006
    Posts
    38

    Storing a vba lookup in an array

    Hi,

    I would like to do the following:

    From an array populated by country codes i would like to lookup the country name in a named range on the form: CountryCode CountryName, i.e. the second column. Then for each country code in the first array, the found name should be stored in another array. Why wont this work f.x.:

    For i = 1 to whatever
    CountryNames(i) = Application.Match(CountryCode(i), CountryCodeArrayRange, 0).Offset(0, 1).Value
    Next i

    I might be making som "obvious" mistake, so please tell me if so!

  2. #2
    Toppers
    Guest

    RE: Storing a vba lookup in an array

    Try:

    For i = 1 to whatever
    CountryNames(i) = Application.VLOOKUP(CountryCode(i),
    CountryCodeArrayRange, 2,0)
    Next i

    HTH

    "erikhs" wrote:

    >
    > Hi,
    >
    > I would like to do the following:
    >
    > From an array populated by country codes i would like to lookup the
    > country name in a named range on the form: CountryCode CountryName,
    > i.e. the second column. Then for each country code in the first array,
    > the found name should be stored in another array. Why wont this work
    > f.x.:
    >
    > For i = 1 to whatever
    > CountryNames(i) = Application.Match(CountryCode(i),
    > CountryCodeArrayRange, 0).Offset(0, 1).Value
    > Next i
    >
    > I might be making som "obvious" mistake, so please tell me if so!
    >
    >
    > --
    > erikhs
    > ------------------------------------------------------------------------
    > erikhs's Profile: http://www.excelforum.com/member.php...o&userid=32788
    > View this thread: http://www.excelforum.com/showthread...hreadid=567054
    >
    >


+ 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