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
[TABLE="width: 667"]
<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>[TR]
[TD="class: xl65, width: 159"]Full Property Number[/TD]
[TD="class: xl66, width: 131"]Full Cust Number[/TD]
[TD="class: xl66, width: 159"]Full Property Number[/TD]
[TD="class: xl67, width: 218"]Inbox name[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]11504[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]11504[/TD]
[TD="class: xl70"]E M&B Meter Under Review[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]197706[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]197706[/TD]
[TD="class: xl70"]E M&B Meter Under Review[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]197706[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]197706[/TD]
[TD="class: xl70"]E M&B SiteMeters different tow[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]255578[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]255578[/TD]
[TD="class: xl70"]E M&B Meter Under Review[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]271534[/TD]
[TD="align: right"]6599300[/TD]
[TD="align: right"]271534[/TD]
[TD="class: xl70"]E M&B Combination Meters[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]396423[/TD]
[TD="align: right"]1968319[/TD]
[TD="align: right"]396423[/TD]
[TD="class: xl70"]E M&B Combination Meters[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]428535[/TD]
[TD="align: right"]2554256[/TD]
[TD="align: right"]428535[/TD]
[TD="class: xl70"]E M&B Meter Under Review[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]480070[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]480070[/TD]
[TD="class: xl70"]E M&B SiteMeters different tow[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]1024809[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1024809[/TD]
[TD="class: xl70"]E M&B LPS Occ Rapid Demolished[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]1192760[/TD]
[TD="align: right"]1024193[/TD]
[TD="align: right"]1192760[/TD]
[TD="class: xl70"]E M&B Belfast Harbour[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]1192966[/TD]
[TD="align: right"]9162885[/TD]
[TD="align: right"]1192966[/TD]
[TD="class: xl70"]E M&B Belfast Harbour[/TD]
[/TR]
[TR]
[TD="class: xl71, align: right"]1192966[/TD]
[TD="class: xl72, align: right"]9162885[/TD]
[TD="class: xl72, align: right"]1192966[/TD]
[TD="class: xl73"]E M&B LPS Missing properties[/TD]
[/TR]
</tbody>[/TABLE]

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
[TABLE="width: 1392"]
<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>[TR]
[TD="width: 92"]Rapid Prop Ref[/TD]
[TD="width: 102"]index[/TD]
[TD="width: 291"]List - 53897[/TD]
[TD="width: 240"]INBOXES[/TD]
[TD="width: 347"]This Property appears in [No of] Workstreams[/TD]
[TD="class: xl18, width: 154"]TEL CLOSED COUNT (col J)[/TD]
[TD="class: xl18, width: 166"]Closed CMS Inboxes (col K)[/TD]
[/TR]
[TR]
[TD="align: right"]11504[/TD]
[TD]20170428-1619[/TD]
[TD]Descoped From M2B Desktop Required[/TD]
[TD]E M2B to M&B On hold[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]11504[/TD]
[TD]20170428-27569[/TD]
[TD]MUR Ready For B&R[/TD]
[TD]E M&B Meter Under Review[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]197706[/TD]
[TD]20170428-26005[/TD]
[TD]MUR Desktop Required[/TD]
[TD]E M&B Meter Under Review[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]2[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]197706[/TD]
[TD]20170428-36653[/TD]
[TD]Site Meter Properties in Different Towns[/TD]
[TD]E M&B SiteMeters different tow[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]2[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]255578[/TD]
[TD]20170428-26013[/TD]
[TD]MUR Desktop Required[/TD]
[TD]E M&B Meter Under Review[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]255578[/TD]
[TD]20170428-42127[/TD]
[TD]Unmatched Properties[/TD]
[TD]E M&B LPS Unmatched properties[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]271534[/TD]
[TD]20170428-36674[/TD]
[TD]Site Meter Properties in Different Towns[/TD]
[TD]E M&B SiteMeters different tow[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]271534[/TD]
[TD]20170428-41348[/TD]
[TD]Unknown Combis 010317[/TD]
[TD]E M&B Combination Meters[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]396423[/TD]
[TD]20170428-23106[/TD]
[TD]Missing Properties[/TD]
[TD]E M&B Missing Properties[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]396423[/TD]
[TD]20170428-41351[/TD]
[TD]Unknown Combis 010317[/TD]
[TD]E M&B Combination Meters[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]428535[/TD]
[TD]20170428-7476[/TD]
[TD]Dom on Rapid, Dom Agri on LPS[/TD]
[TD]E M&B LPS Dom Agri[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]428535[/TD]
[TD]20170428-27581[/TD]
[TD]MUR Ready For B&R[/TD]
[TD]E M&B Meter Under Review[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]480070[/TD]
[TD]20170428-28556[/TD]
[TD]Occupied LPS, Demolished Rapid[/TD]
[TD]E M&B LPS Occ Rapid Demolished[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]480070[/TD]
[TD]20170428-36700[/TD]
[TD]Site Meter Properties in Different Towns[/TD]
[TD]E M&B SiteMeters different tow[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]1024809[/TD]
[TD]20170428-28843[/TD]
[TD]Occupied LPS, Demolished Rapid[/TD]
[TD]E M&B LPS Occ Rapid Demolished[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]1024809[/TD]
[TD]20170428-36721[/TD]
[TD]Site Meter Properties in Different Towns[/TD]
[TD]E M&B SiteMeters different tow[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]1192760[/TD]
[TD]20170428-10[/TD]
[TD]Belfast Harbour[/TD]
[TD]E M&B Belfast Harbour[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]1192760[/TD]
[TD]20170428-24172[/TD]
[TD]Missing Properties[/TD]
[TD]E M&B Missing Properties[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]1[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]1192966[/TD]
[TD]20170428-12[/TD]
[TD]Belfast Harbour[/TD]
[TD]E M&B Belfast Harbour[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]2[/TD]
[TD="class: xl18"][/TD]
[/TR]
[TR]
[TD="align: right"]1192966[/TD]
[TD]20170428-24176[/TD]
[TD]Missing Properties[/TD]
[TD]E M&B Missing Properties[/TD]
[TD="align: right"]2[/TD]
[TD="class: xl18, align: right"]2[/TD]
[TD="class: xl18"][/TD]
[/TR]
</tbody>[/TABLE]



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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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