Help with VBA AdvancedFilter

sidel801

New Member
Joined
Nov 2, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
There's a code I found online that does almost exactly what I was hoping for, that is, automatically filter an entire row when a cell (E7 in my example) value changes. The problem I'm having is whenever something changes in the worksheet, it triggers the macro. Is there any way to limit the trigger so it only happens (i.e., filters) when I change the value of that particular cell rather than any change in the worksheet? See below....

Thanks in advance for any help you can provide!

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count < Me.Columns.Count Then
Range("e10:e80").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range _
("e6:e7"), Unique:=False

End If
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Please, try if this could work there.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 If Target.Address = "$E$7" And Target.Columns.Count < Me.Columns.Count Then
  Range("E10:E80").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("E6:&7"), Unique:=False
 End If
End Sub
 
Upvote 0
Please, try if this could work there.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 If Target.Address = "$E$7" And Target.Columns.Count < Me.Columns.Count Then
  Range("E10:E80").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("E6:&7"), Unique:=False
 End If
End Sub
 
Upvote 0
No unfortunately! The filtering doesn't seem to be working now. I was hoping to use XL2BB to upload something, but I can't seem to open the excel add-in...sorry.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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