Worksheet change event

Fwiz

Board Regular
Joined
May 15, 2007
Messages
241
hi,

just look at the worksheet change event, I'm trying to run autofiler if any value on column G has changed value - I've got some code but cannot get it to work.....

Sub Worksheet_Change(ByVal Target As Range)

'If Target.Row > 2 And Target.Column = 7 Then
If Target.Address = "$G$3:$G$65536" Then
Selection.AutoFilter Field:=7, Criteria1:="=Unpaid", Operator:=xlAnd
Range("A1").Select
End If
End Sub

any suggestions??
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Instead of:

Code:
If Target.Address = "$G$3:$G$65536" Then

try:

Code:
If Not Application.Intersect(Target, Range("$G$3:$G$65536")) Is Nothing Then
 
Upvote 0
I've added this in, it seems to filter on a couple of items, when I change values again the macro doesnt run...... any thoughts?
 
Upvote 0
it doesnt seem to fire each time i change a new value, i'm expecting the auto filter to filter out the paid items to leave me with the unpaid ones.... ?
 
Upvote 0
How are the values in $G$3:$G$65536 changed??
Via Manual data entry, or Via Formula??
 
Upvote 0
It's probably related to the use of Selection on the Autofilter line...
Selection may not be what you think it is...

I assume row 2 is headers,
Try

Code:
Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("$G$3:$G$65536")) Is Nothing Then
    Range("G3").CurrentRegion.AutoFilter Field:=7, Criteria1:="=Unpaid", Operator:=xlAnd
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,629
Members
452,933
Latest member
patv

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