excel - VBA Lookup value, return all unique values associated with the lookup value (in userform textbox) -


What I'm trying to do is use VBA to get the boundaries of Vlookup, and create a userform Which is a customer number. I have a column full of duplicate value (customer number), then there are unique values ​​(customer events) in the column next to it. Here is a small part of my table:

  123 calls made to Costman Cost cost 123 calls 345 complaints 345 345 received refund accepted   

I created a user that allows our employees to search through column A, and gives what happens in column B. I did it with vLookup, but everyone knows the limitations of VLcup, because it will only return the first value in B which will run it.

Order

Search for me to display five customer event hits at the top for my user textbox Needed: Ultimately it can be run through SQL tables that I do not have access to write, so changing data is not an option.

My code:

  x = cnum.Value textbox1.Value = Application.WorksheetFunction.VLookup (X, Range ("A2: B 5 "), 2, Incorrect)   

You can use the VBA function You can use. I wrote the function; it can be made stronger; But this should give you the original idea.

Enter image details here

the code behind it The simple task that will take the ID as its logic and then return all related records. Idea based Alan Brown's

  Public Function Concat Related (Input ID as Long) string long as long as the dim, for long as the ICTR, the last as the straight Line = range ("A65536"). End (XLEEP). ICT = 1 to the last if the cells (ICTR, 1). Value = input ip then retStr = retStr & amp; Room (ICTR, 2). Value & amp; "," If the next if lane (ratest)> 0 then _ retStr = Left (retStr, Len (retStr) - 2) concatRelated = retStr End Function   

I hope this will be helpful! Good luck.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -