VBA Code to filter Sheet2 data based on Shee1 Cell Value

shaikhstonevilla

New Member
Joined
Dec 5, 2012
Messages
23
Hi,

Thank you in advance.

Can you please help me with the VBA code so that when i enter value in Sheet1 A2 cell then Sheet 2 A1:P will automatically be filtered.


Thank you.

Shaikhstonevilla
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Put the following code in the events of your sheet1

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address(False, False) = "A2" Then
        If Target.Count > 1 Then Exit Sub
        Sheets("Sheet2").Range("A1").AutoFilter Field:=1, Criteria1:=Target.Value
    End If
End Sub

SHEET EVENT
Right click the tab of the sheet you want this to work, select view code & paste the code into the window that opens up.
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,530
Members
448,969
Latest member
mirek8991

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