lookup function return range
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Lookup function to return a range of Cells

Lookup function to return a range of Cells

resolvedResolved · High Priority · Version 2003

replyReply Tue 11 Aug 2009, 09:41Delegate Gareth said...

Gareth has attended:
Excel VBA Intro Intermediate course
Excel Intermediate course
Excel Advanced course

Lookup function to return a range of Cells

Hello

Im having a slight problem. I am looking to create a 'search engine' in excel that would automatically bring back a range of cells, from another worksheet.

For example. In cell A1 I would input a Beat Code such as D4550A. In Cell B1 I would then gather a list of staff who are working on that beat.

I have tried the v lookup function however this only returns one row of data, whereas I might be looking to return 10 or 15 rows based on who has got the beat code D4550A next to their name.

Is there any other method or adaptions to the vlookup formula that could return a range of cells, rather than just the one row?

Thanks in advance

Gareth.

For upcoming training course dates see: Pricing & availability

replyReply Wed 12 Aug 2009, 14:10Trainer Anthony said...

RE: Lookup function to return a range of Cells

Hi Gareth, thanks for your query. You could achieve this using an advanced filter and specifying the criteria range, but the results would be outputted to individual cells. You said "In Cell B1 I would then gather a list of staff who are working on that beat". Do you intend to concatenate the results and output them to B1? If so, be aware the Concatenate function does not accept range references, and you'll have to use the "&" operator to link each result. As such you will have to cycle through the results from the filter using a loop, which therefore means you'll need to use VBA. A macro to achieve what you want shouldn't be too difficult, just take the contents of cell A1, use it to filter out the data from the table, then select the resulting range, concatenate it (either looping through the range and using "&" or using a bespoke Function to do so) and output it to cell B1. Fiddly, but not impossible.

Hope this helps,

Anthony

Wed 19 Aug 2009: Automatically marked as resolved.

 

Please browse our web site to find out more about
microsoft excel training courses london and other Microsoft training courses.

Excel tip:

Generating Random Numbers

To generate a random number in Excel use the = RAND() function.

The value returned will always be between 0 and 1. To convert this to some other random value, you will need to multiply the result by the highest number you want to consider. For example, if you wanted a random number between 1 and 25, you could use the following code line:
= INT(25 * RAND()+ 1)

Since RAND() will always returns a value between 0 and 1 (but never 1 itself), multiplying what it returns by 25 and then using the Integer function INT on that result will return a whole number between 0 and 24.

Finally, 1 is added to this result, so that x will be equal to a number between 1 and 25, inclusive

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard