• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VLOOKUP to Return whole horizontal row values in vba

Hi sir,
I need an UDF macro function for VLOOKUP to Return whole horizontal row values. ie when Select Drop Down list in sheet1 (Noun-Modifier), then
Sheet 2 Catted Value automatically populated as per example attached sample file. Could you resolve my query.
 

Attachments

AlanSidman

Well-Known Member
Used a combination of Power Query and Power Pivot to achieve your expected results as shown in the attached.
Unpivot your data in Power Query and then load the data into the data model to allow a measure to be built to show your data in a pivot table with a Pipe delimiter.
 

Attachments

Thanks for your reply sir.. Am currently using excel 2007..so i dont have power query and power pivot.that why am asking you to solve this query in vba function. Could you help me.
 

BobBridges

Active Member
Jeya, you can write a VBA program that can find a row and do something with it, perhaps copy all its values somewhere. But it wouldn't be a UDF; a user-defined function cannot return a whole row, only a single value.
 

BobBridges

Active Member
One correction: When I say you can't do it, I mean in a worksheet function. If you enter a worksheet function in a cell (eg "=SUM(A5:A23)"), it can return only a single value whether it's a built-in function or a VBA program you wrote yourself.

But if you're talking about a function called by another VBA program, that function can indeed return an Excel object, including a Row object. Which did you mean?
 

BobBridges

Active Member
I'm not sure. I suppose it depends on this: What do you want to do with the row once your routine has identified it? There are usually ways to accomplish what you want, even if you can't do it the way you were asking about.
 

p45cal

Well-Known Member
In the attached, horrible formula in cell D2 and below of sheet Sheet1, copied across every 3rd column:
Code:
=SUBSTITUTE(TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(VLOOKUP($C2,Sheet2!$A$2:$B$16,2,0)," ","¬"),"|"," ")," ",REPT(" ",1000)),(VALUE(SUBSTITUTE(D$1,"Attribute ",""))-1)*1000+1,1000)),"¬"," ")
This formula returns #N/A when it doesn't find what's being looked up so you could wrap the entire formula in an IFERROR function.
 

Attachments

Thanks for reply sir..this formula works fine.But some time Excel hangs and Not responding frequently. Is there any changes Needed?
 
Top