Updating AdvancedFilter in VBA does not work

DaiCar

New Member
Joined
Aug 22, 2017
Messages
2
Dear Excel-Masters,

As a newbie to this Forum I have a request I have been working on some hours now :p I have been charged with building an Excel-based customer database. Therefore, I wanted to build an Advanced Filter in VBA to copy the data from the database to a new sheet :)

So far the following code has worked once and the other solutions to this problem have not been fruitful. There must be a mistake somewhere but I can't find it...

Table1 ("List") = target sheet
Table2 ("Core_Data") = source sheet
Also I have created a range name called "Core_Data" which should adjust dynamically to the whole sheet:

=Core_Data!$A$2:INDEX(Core_Data!$A:$P;COUNTA(Core_Data!$A:$A);COUNTA(Core_Data!$1:$1))

Module Sub:

Sub FilterMeAdvanced()
Calculate
Tabelle1.Range("A8").Select
Range("Core_Data").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
Range("W1:AB2"), CopyToRange:=Range("A8:P8"), Unique:=False
End Sub

Worksheet-Function (supposed to refresh after changing the filter criterion):

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Worksheet.Name = "List" And Target.Column = 1 And Target.Row = 4 _
Or Target.Column = 2 And Target.Row = 4 _
Or Target.Column = 3 And Target.Row = 4 _
Or Target.Column = 4 And Target.Row = 4 _
Or Target.Column = 5 And Target.Row = 4 _
Or Target.Column = 6 And Target.Row = 4 _
Or Target.Column = 7 And Target.Row = 4 _
Or Target.Column = 8 And Target.Row = 4 _
Or Target.Column = 9 And Target.Row = 4 _
Or Target.Column = 10 And Target.Row = 4 _
Or Target.Column = 11 And Target.Row = 4 _
Or Target.Column = 12 And Target.Row = 4 _
Then
Application.SendKeys ("%{down}")
End If
End Sub

So far the filter worked once (by using the Sub) and hasn't changed ever since

Many thanks in advance for your help :)
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I have realized that this dynamic range name is problematic - does somebody know how create a dynamic range name list? This code seems to be wrong:

=Core_Data!$A$2:INDEX(Core_Data!$A:$P;COUNTA(Core_Data!$A:$A);COUNTA(Core_Data!$1:$1))
 
Upvote 0

Forum statistics

Threads
1,215,049
Messages
6,122,864
Members
449,097
Latest member
dbomb1414

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