What you've got so far looks to me like a recorded macro - if next time
you run it the filtered area is A1:O25 your macro is unfortunately only
going to copy area A1:O22!
Have a go with this:
If ActiveSheet.AutoFilterMode = True Then
Range("A1").AutoFilter
End If
Range("A1").AutoFilter Field:=1, Criteria1:="Y"
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range
rng.copy
ChDrive "P"
ChDir "P:\Daily &Reports\"
Dim MyXlPathway As String
MyXlPathway = Application.GetOpenFilename("Excel Files (*.xls),
*.xls", 1, "Select the Excel file you wish to copy data into........")
Workbooks.Open MyXlPathway, , True
range("A1").paste
you might need to change a few little details (e.g drive and directory)
to suit your needs
Regards
J
On Nov 24, 4:05 pm, Mannie G
wrote:
I have a Macro for extracting price options from a large pricelist with
several sheets. The Macro always copies to a workbook "MachineQuote1". How
can I make the macro copy to any selected workbook? I am a novice at working
with VB and Macros. The code is currently:-
Range("A1").Select
Selection.AutoFilter
Range("A1").Select
Selection.AutoFilter Field:=1, Criteria1:="Y"
Range("A1:O22").Select
Selection.Copy
Windows("MachineQuote1").Activate
ActiveCell.Select
ActiveSheet.Paste
ActiveCell.Select
Windows("RembrandtPriceList2006+AMJMPrices-17May06.xls").Activate
Application.CutCopyMode = False
Selection.AutoFilter
ActiveCell.Select
Windows("MachineQuote1").Activate
End Sub
--
Thanks
Mannie G