Macro for auto filtering based on cell value

likun6

New Member
Joined
Sep 27, 2017
Messages
2
Hi All,

Could someone please help me to write a macro that filters the selection of data based on a cell value?

The situation is:

Let's say I have 2 columns A & B, and I have 2 other cells that I can enter value in them.

I need the macro to auto filter column B by searching the content of cell 1, and then also auto filter column C by searching the content of cell 2.

Using the example below, if I enter grape and paper into Cell 1 and 2 respectively, then it should automatically filter for rows 6-8.


[TABLE="width: 495"]
<colgroup><col><col><col span="4"></colgroup><tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD][/TD]
[TD][/TD]
[TD]Cell 1[/TD]
[TD]Cell 2[/TD]
[/TR]
[TR]
[TD]orange[/TD]
[TD]rock & lemon[/TD]
[TD][/TD]
[TD][/TD]
[TD]grape[/TD]
[TD]paper[/TD]
[/TR]
[TR]
[TD]orange[/TD]
[TD]rock & apple[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]orange[/TD]
[TD]rock[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]orange[/TD]
[TD]paper[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]orange[/TD]
[TD]scissor[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]grape[/TD]
[TD]paper & lemon[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]grape[/TD]
[TD]paper & apple[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]grape[/TD]
[TD]paper[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]grape[/TD]
[TD]rock[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]grape[/TD]
[TD]scissor[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


I really appreciate any help provided, and happy to clarify if it doesn't make sense!

Many thanks!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Sorry it's supposed to say:

I need the macro to auto filter column A by searching the content of cell 1, and then also auto filter column B by searching the content of cell 2.


Apologies for the confusion!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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