Vlookup - Multipel results

L

Les Stout

Good day,

i am very new at this game and have written some code to do a Vlookup to
find the name entered into an input box, it works fine but the problem
is there are at times more than one with the same Surname!
Could somebody help me with some code that would enable me either see a
list of the names or to "find next" and display?


Les Stout
 
T

Tom Ogilvy

Try applying an Autofilter to your data (Data=>Filter=>Autofilter). Set the
surname filter to the surname of interest and all lines with that surname
will be visible, while others will be hidden. If you need a macro, you can
turn on the macro recorder while doing it manually. It is only a single
command with a few arguments. Vlookup would be the wrong command to use.
Match would tell you the first row where the data is found, so if you don't
want to use the autofilter, you would use match and then if the list is
sorted by surname, you could search below that location. Another approach
would be to use the Find method of the range object. The example code in
the help file shows you how to search for multiple instances. The would be
expecially appropriate if your list is not sorted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top