jrobin5881
Technical User
I have a dataset that I am filtering on a combo box. I read many of the posts here concerning Advanced filtering and there was a thread (which I lost the name and number of)that walked you through setting up a filter using VBA and it worked fine. The thread went on to say that you could copy the filtered data and paste it into another sheet which is what I want to do with a little of the code tweaked. The DropDown_Change sub worked fine(see below) but I'm getting an error message when I replace that code with the Extract_Data sub.
The message says"The extract range has a missing or illegal field name" I tried naming a range "ext" (no quotes) in the same sheet & in another sheet to make it work to no avail.
Whats wrong? why did it run fine for the first code but not the second?
PS: Code is written in a module and is assigned as a macro to a FORM combo box on the database page.
Sub DropDown_Change()
crit = [crit_type].Value
Range("dataset").AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=crit, _
Unique:=False
Extract_Data
End Sub
Sub Extract_Data()
Range("dataset").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=crit, _
CopyToRange:=Range("ext"), Unique:=False
End Sub
The message says"The extract range has a missing or illegal field name" I tried naming a range "ext" (no quotes) in the same sheet & in another sheet to make it work to no avail.
Whats wrong? why did it run fine for the first code but not the second?
PS: Code is written in a module and is assigned as a macro to a FORM combo box on the database page.
Sub DropDown_Change()
crit = [crit_type].Value
Range("dataset").AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=crit, _
Unique:=False
Extract_Data
End Sub
Sub Extract_Data()
Range("dataset").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=crit, _
CopyToRange:=Range("ext"), Unique:=False
End Sub