VBA Sort Table By Certain Word or Cell Value

Ottsel

Board Regular
Joined
Jun 4, 2022
Messages
174
Office Version
  1. 365
Platform
  1. Windows
I have a table that Column two contains an array of items.

ListObjects("ItemInventory")

Range A5 contains the item I want the table to sort by. Currently the item inventory is quite large, so it can take time to sort through everything to find the one item you want to show.

How would I structure it so if Range A5 contained "Lamps" that a button would sort the table by column two (which is labeled 'Items") to only show rows that contain "Lamps"?

Any tips, tricks or help would be greatly appreciated!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Would it be simpler to just filter the items column in the table and add a text filter > contains > type in some partial/whole match? (Or enter lamps in the search field when clicking the filter drop-down for that column?)

Otherwise you could use a VBA filter macro linked to a button, or as part of a Worksheet_Change event looking at cell A5:
VBA Code:
ActiveSheet.Range("$A$10:$G$2000").AutoFilter Field:=1, Criteria1:="=*" & Range("A5").Value & "*", Operator:=xlAnd
 
Upvote 0
Solution
Would it be simpler to just filter the items column in the table and add a text filter > contains > type in some partial/whole match? (Or enter lamps in the search field when clicking the filter drop-down for that column?)

Otherwise you could use a VBA filter macro linked to a button, or as part of a Worksheet_Change event looking at cell A5:
VBA Code:
ActiveSheet.Range("$A$10:$G$2000").AutoFilter Field:=1, Criteria1:="=*" & Range("A5").Value & "*", Operator:=xlAnd
Appreciate the idea! Thank you.
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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