sub copytowk
Range("A1").AutoFilter Field:=1, Criteria1:="Y"
Range("A1:O22").Copy
workbooks("MachineQuote1.xls").sheets("yoursheet") .range("a1")
End Sub
Or you can make a list of workbook namesright click sheet tabview
codeinsert thisdouble click on the cell with the name of the workbook.
Modify to suit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
With Workbooks("sourceworkbookname.xls").Sheets("source sheet")
Range("A1").AutoFilter Field:=1, Criteria1:=1
Range("A1:O22").Copy Workbooks(workbookname &
".xls").Sheets("sheet1").Range("a1")
..Range("a1").AutoFilter
End With
End Sub
sub copytowk
'mywb=target
Range("A1").AutoFilter Field:=1, Criteria1:="Y"
Range("A1:O22").Copy
workbooks("MachineQuote1.xls").sheets("yoursheet") .range("a1")
End Sub
--
Don Guillett
SalesAid Software
"Mannie G" wrote in message
...
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