vlookup variation??

alanoreilly

Board Regular
Joined
Dec 4, 2003
Messages
56
Is it possible to use a vlookup to produce a number of results…

I have a list of surnames, and I want to use the vlookup to find all the Smiths in the list, obviously a basic vlookup only brings back the first Smith it finds….

=vlookup(A1, download,1,false) , where A1 is some sort of search box for users

or is there a simple VB solution??
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hello,

If you are prepared to do it manually use DATA, FILTER and check AUTOFILTER, or if you do want it automated, VB is probably the best way to go.
 
Upvote 0
alanoreilly said:
Is it possible to use a vlookup to produce a number of results…

I have a list of surnames, and I want to use the vlookup to find all the Smiths in the list, obviously a basic vlookup only brings back the first Smith it finds….

=vlookup(A1, download,1,false) , where A1 is some sort of search box for users

or is there a simple VB solution??

Your question is a bit ambiguous. Given a list like:

Smith
Smith
Doe
Smith

I'd just count Smith's with N as result and print out Smith N times.

I suspect that this is not what you want. If not, care to post a small sample and the result that you want to see?
 
Upvote 0
on one sheet there is a list of names and personal details...(here I'm just showing names for ease of use, see list below)

on a second sheet is a search fuinction, If Smith is typed in A1, the vlookup will only give the first Smith on the list below, I want to get all the Smiths on the list

=VLOOKUP(A1,list,1,FALSE)


NAME
murphy
smith
johnson
smith
henry
cash
law
smith
rushton
rolls
smith
hartman
smith


I hope this is clearer

Thanks
Alan
 
Upvote 0
alanoreilly said:
on one sheet there is a list of names and personal details...(here I'm just showing names for ease of use, see list below)

on a second sheet is a search fuinction, If Smith is typed in A1, the vlookup will only give the first Smith on the list below, I want to get all the Smiths on the list

=VLOOKUP(A1,list,1,FALSE)


NAME
murphy
smith
johnson
smith
henry
cash
law
smith
rushton
rolls
smith
hartman
smith


I hope this is clearer

Thanks
Alan

I suppose you want to retrieve the details too. Right? Otherwise, my initial reply will still apply.
 
Upvote 0
you'll have to excuse my ignorance but I don't know what the following means...

"I'd just count Smith's with N as result and print out Smith N times"

could you dumb it down a little???

thanks
alan
 
Upvote 0
alanoreilly said:
you'll have to excuse my ignorance but I don't know what the following means...

"I'd just count Smith's with N as result and print out Smith N times"

could you dumb it down a little???

thanks
alan

Lets forget that Alan. Is it your intention also retrieve the details of each Smith?
 
Upvote 0
I'll just assume that you want to retieve details involving a name...

Sheet1 houses the data (the lookup table)
Book7
ABCD
1NAMEADDRESSPHONECREDITLIMIT
2murphyadd001phone001400.00
3smithadd002phone002400.00
4johnsonadd003phone003200.00
5smithadd004phone004400.00
6henryadd005phone005200.00
7cashadd006phone006400.00
8lawadd007phone007400.00
9smithadd008phone008400.00
10rushtonadd009phone009400.00
11rollsadd010phone010400.00
12smithadd011phone011500.00
13hartmanadd012phone012100.00
14smithadd013phone013200.00
Sheet1


Method 1

A side note. This collapses a number of formula systems of mine for returning multiple values and Just_Jon's (see: http://216.92.17.166/board2/viewtopic.php?t=73228)...

Select A2:D14.
Go to the Name Box on the Formula Bar, type LTable, and hit enter.

Sheet2a

Select B1.
Activate Data|Validation.
Choose List for Allow.
Enter the following in the Source box:

=INDEX(LTable,0,1)

Click OK.

In A2 enter: Pos [ just a label, abbreviated from Position ]

In B2 enter:

=COUNTIF(INDEX(LTable,0,1),B1)

In A3 enter & copy down:

=IF(COUNTA($A$2:A2)<=$B$2,MATCH($B$1,INDEX(Sheet1!A:A,N(A2)+1):INDEX(Sheet1!A:A,MATCH(BigStr,Sheet1!A:A)),0)+N(A2),"")

In B3 enter, copy across, then down:

=IF(N($A3),INDEX(Sheet1!A:A,$A3),"")

Method 2

Sheet2b
Book7
ABCD
1NAME
2smith
3NAMEADDRESSPHONECREDITLIMIT
4smithadd002phone002400.00
5smithadd004phone004400.00
6smithadd008phone008400.00
7smithadd011phone011500.00
8smithadd013phone013200.00
9
Sheet2b


In A1 enter: NAME [ a label from LTable ]

Select A2.
Activate Data|Validation.
Choose List for Allow.
Enter the following in the Source box:

-INDEX(LTable,0,1)

Click OK.

Select A1:A2.
Activate Data|Filter|Advanced Filter.
Check Copy to another location.
Enter Sheet1!$A$1:$D$14 in the box for List range.
Enter Sheet2b!$A$1:$A$2 in the box for Criteria range.
Enter Sheet2b!$A$3 in the box for Copy to.
Leave Unique records only unchecked.
Click OK.

The foregoing Advanced Filter is not automatic, although you can record a macro which you can play at will.
 
Upvote 0
alanoreilly said:
thanks, that's perfect, apologies for the delay I had run to a meeting

Thanks again,
Alan

For Method 1, you need to define BigStr, which I forgot to include:

Activate Insert|Name|Define.
Enter BigStr in the Names in Workbook box.
Enter the following in the Refers to box:

=REPT("z",255)

Click OK.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top