View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected][_2_] rrstudio2@icqmail.com[_2_] is offline
external usenet poster
 
Posts: 29
Default Matching IDs with Names (VB)

Lets say I have a workbook with ID numbers in it. I have a macro
doing a lot of work on this workbook and one of the things I want it
to do is to convert the ID numbers into names. I haven't done this
with VB before and was wondering what the best/easiest way to do this
would be? If I wasn't doing it with a macro, I would just have a
vlookup, but this isn't an option for my case. I have looked into
arrays, but this seems like it would be hard to populate and search
thru. My idea was to create two arrays:

IDs = Array (1111,2222,3333,4444)
Names = Array("Bob","John","Henry","Sue")

The real data would contain about 20 elements. I would rarely if ever
need to add or change IDs/Names. Then as I find the ID value in the
cell, it would look thru the ID array, find the index of the value,
the pull up the corresponding index in the names array. This seems
cumbersome and I am sure there has to be a better way to do this.

Thanks,
Andrew V. Romero