Returning Multiple Values Through A Vlookup - Formula or VBA

liamlarmour

New Member
Joined
May 4, 2017
Messages
4
Context:

I regularly use Vlookups in my work as part of a project, but as you may be aware, they can only return one value from the lookup column. For month-end reporting I need to determine if a particular account as a record in the relevant system inboxes, if it appears in more than one workstream (we have CorVu reports run that listing all unique IDs with a lot of relevant details and then the inbox the record has been created in. We have approx 50k unique IDs (2100 of these belong to 2 or 3 workstreams and so should have a record in each relevant inbox), with approx 7000 open queries in one report, and 9000 closed queries in another. As part of my reporting, I must constantly track these every month, with one part of this matching our unique IDs from a master list to each open and closed report, to return the relevant inboxes if the unique ID appears in either report.

Raw data (yellow column is a helper col inserted to run other vlookups from) - this report is cols A-AU, I insert a helper col in which becomes the new A, so the lookup col is AV. I have hidden columns for customer privacy.
a b c av
Full Property NumberFull Cust NumberFull Property NumberInbox name
11504011504E M&B Meter Under Review
1977060197706E M&B Meter Under Review
1977060197706E M&B SiteMeters different tow
2555780255578E M&B Meter Under Review
2715346599300271534E M&B Combination Meters
3964231968319396423E M&B Combination Meters
4285352554256428535E M&B Meter Under Review
4800700480070E M&B SiteMeters different tow
102480901024809E M&B LPS Occ Rapid Demolished
119276010241931192760E M&B Belfast Harbour
119296691628851192966E M&B Belfast Harbour
119296691628851192966E M&B LPS Missing properties

<colgroup><col width="159" style="width:119pt"> <col width="131" style="width:98pt"> <col width="159" style="width:119pt"> <col width="218" style="width:164pt"> </colgroup><tbody>
</tbody>

I usually create a blank tab, copy out the Property Refs (unique IDs), remove duplicates and then try to obtain the details I need.
a d e f g
Rapid Prop RefindexList - 53897INBOXESThis Property appears in [No of] WorkstreamsTEL CLOSED COUNT (col J)Closed CMS Inboxes (col K)
1150420170428-1619Descoped From M2B Desktop RequiredE M2B to M&B On hold21
1150420170428-27569MUR Ready For B&RE M&B Meter Under Review21
19770620170428-26005MUR Desktop RequiredE M&B Meter Under Review22
19770620170428-36653Site Meter Properties in Different TownsE M&B SiteMeters different tow22
25557820170428-26013MUR Desktop RequiredE M&B Meter Under Review21
25557820170428-42127Unmatched PropertiesE M&B LPS Unmatched properties21
27153420170428-36674Site Meter Properties in Different TownsE M&B SiteMeters different tow21
27153420170428-41348Unknown Combis 010317E M&B Combination Meters21
39642320170428-23106Missing PropertiesE M&B Missing Properties21
39642320170428-41351Unknown Combis 010317E M&B Combination Meters21
42853520170428-7476Dom on Rapid, Dom Agri on LPSE M&B LPS Dom Agri21
42853520170428-27581MUR Ready For B&RE M&B Meter Under Review21
48007020170428-28556Occupied LPS, Demolished RapidE M&B LPS Occ Rapid Demolished21
48007020170428-36700Site Meter Properties in Different TownsE M&B SiteMeters different tow21
102480920170428-28843Occupied LPS, Demolished RapidE M&B LPS Occ Rapid Demolished21
102480920170428-36721Site Meter Properties in Different TownsE M&B SiteMeters different tow21
119276020170428-10Belfast HarbourE M&B Belfast Harbour21
119276020170428-24172Missing PropertiesE M&B Missing Properties21
119296620170428-12Belfast HarbourE M&B Belfast Harbour22
119296620170428-24176Missing PropertiesE M&B Missing Properties22

<colgroup><col width="92" style="width:69pt"> <col width="102" style="width:77pt"> <col width="291" style="width:218pt"> <col width="240" style="width:180pt"> <col width="347" style="width:260pt"> <col width="154" style="width:116pt"> <col width="166" style="width:125pt"> </colgroup><tbody>
</tbody>



Possible Solution:

I came across another thread from 2009 for hiker95's "VLookUpMulti" function (http://www.mrexcel.com/forum/excel-questions/439622-returning-multiple-values-through-vlookup.html) which is exactly what I have been looking for. I have tried to tweak this and I can't work out how to do it.

Reasons for tweaking:

It is a user-defined function (UDF). The code works well if it is searching within a table of only two columns, eg unique ID and lookup column. I assume this is to do with the sample data used in the thread. So in an attempt to see if it works for my means, I tried it with a smaller sample of two columns and it worked. However when I tried it looking up the values from a third column (specifying this in the formula) it still only returned values from the second column.

1) I need to redefine the VBA code so that I can return values from any lookup column up to and maybe even beyond the final column (if i was to add extra data onto a report for other reasons).
2) The code seems to return numerical data in one order and text data in another. Generally our reports are arranged in chronological order for the created records - so it would be useful to return them in the order created - then I could always retrieve data from other columns go alongside it - this may not work if the returned results are sorted in different orders depending on their numeric or text format.
3) I'm aware that UDFs may only apply to one workbook that it is created in. However I would need to use this in multiple workbooks. Is there a way around this? I've read a couple of different pages around creating it in a separate workbook on its own and saving it as an add-in, activating it and then using it that way. Is that the only, and easiest, way?

Apologies for all the questions, I'm not great at macros at the best of times, and am really trying to get into VBA, but it isn't easy when most sites sometimes presume you already know the basics around most things.

I really appreciate any help offered.

Thanks
Liam

 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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