Lookup and return all values in a row

tryingbeginner

New Member
Joined
Jun 15, 2015
Messages
9
I have a table that follows the same structure as below. Note that in my document it is a very large table (150 rows, 30 columns), so I would like to keep the general formatting of it.

[TABLE="width: 500"]
<tbody>[TR]
[TD]Bob[/TD]
[TD][/TD]
[TD]Table[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Peter[/TD]
[TD]Bed[/TD]
[TD][/TD]
[TD]Couch[/TD]
[TD]Chair[/TD]
[/TR]
[TR]
[TD]Jeff[/TD]
[TD]Bed[/TD]
[TD]Table[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Grace[/TD]
[TD][/TD]
[TD][/TD]
[TD]Couch[/TD]
[TD]Chair[/TD]
[/TR]
[TR]
[TD]Tom[/TD]
[TD]Bed[/TD]
[TD][/TD]
[TD]Couch[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

In another sheet, I have a dropdown box where I can select any of the names in the first box. To the right of their name, I want something like the following table to be generated, where any item to the right of their name in the original table is now in a list.

[TABLE="width: 500"]
<tbody>[TR]
[TD]Name: Peter[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Bed[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Couch[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Chair[/TD]
[/TR]
</tbody>[/TABLE]

I've seen similar (kinda) examples with people using an array like =small(if(range=value, row(range), row()) but that won't be able to work for my application.

Anyone have any ideas with this one, or could point me in the right direction?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I put your original table in sheet "Main" from A1 to AE1 with row 1 being headers.
On the sheet called "Sub" in A2 I put the name to find. This macro lists the items for that person in B2 through Bn.

There surely are other/better ways, but I always look for the first solution I can come up with.

Code:
Sub FindItems()
Dim Prow As Long, i As Long, j As Long
Prow = Application.WorksheetFunction.Match(Sheets("Sub").Range("A2"), Sheets("Main").Range("A1:A151"), 0)
Sheets("Sub").Range("B2:B31").ClearContents
j = 2
For i = 2 To 31
 If Sheets("Main").Cells(Prow, i) <> "" Then
  Sheets("Sub").Cells(j, 2) = Sheets("Main").Cells(Prow, i)
  j = j + 1
  Else
 End If
Next i
End Sub
 
Last edited:
Upvote 0
Code:
 Note that in my document it is a very large table (150 rows, 30 columns)
That's not a large table, do you mean 150K rows?
 
Last edited:
Upvote 0
This was a test/sample. The numbers for rows and columns could be adjusted by the user.
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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