I would like to open Excel from Access and apply filters to a sheet. Below is my code:
Dim s as String
Set oApp = CreateObject("Excel.Application")
oApp.Wworkbooks.Open FileName:="dudel.xlsm"
oApp.Visible = True
s = "AB"
With oApp
.Rows("2:2").Select
.Selection.AutoFilter
.ActiveSheet.Range("$A$2:$D$9000").AutoFilter Field:=3, Criteria1:= _
Array(s, "E", "="), Operator:=xlFilterValues
.Range("A3").Select
End With
When I ran the code, I got this error:
runt time error 1004 Autofilter methond of range class failed
Can anyone see why?
Try this one. I've commented code in details, but if you have some questions - ask:)
and also one more thing: change
Operator:=xlFilterValues
toOperator:=7
(access doesn't know about excel constanst until you add reference to the excel library in access)