Since your code is the event code for a commandbutton on a worksheet, the
code is located in the sheet module
When you do Sheets("Work Order").Select
then the sheet Work Order becomes the active sheet and the sheet with the
button (sheet Van 1) is not longer active. You then do
Range("B2:B8").Select. Your intent it to select this on sheets Work Order,
but since it is unqualified with the sheet name and located in the module
for Van 1, it actually refers to B2:B8 on Sheet Van 1. Since Van 1 is not
the active sheet, the range can not be selected and your code fails.
You can move all the code to a general module and call it from your Click
event or you can fully qualify your references ( and skip the selecting as
well since it isn't necessary).
Private Sub cmdVan1_Click()
Sheets("Van 1 ").Range("B2:B8").Copy _
Destination:=Sheets("Work Order").Range("B2:B8")
Sheets("Van 1 ").Range("C10").Copy _
Destination:=Sheets("Work Order").Range("B12")
Sheets("Van 1 ").Range("E10").Copy _
Destination:=Sheets("Work Order").Range("C12")
Sheets("Service schedule").Range("B2:C2").Copy _
Destination:=Sheets("Work Order").Range("B11:C11")
ActiveWindow.SelectedSheets.PrintOut Copies:=2, Collate:=True
End Sub
This assumes you are printing out Sheets("Van 1") [ which is consistent
with your code]
if not change your printout to
Sheets("Work Order").Printout Copies:=2, Collate:=True
as an example.
--
Regards,
Tom Ogilvy
"fred 616 " wrote in message
...
i am gettin an error evertime the run gets to the range("name").select
can any one help me identify the problem
Private Sub cmdVan1_Click()
Sheets("Van 1 ").Select
Range("B2:B8").Select
Selection.Copy
Sheets("Work Order").Select
Range("B2:B8").Select
ActiveSheet.Paste
Sheets("Van 1 ").Select
Range("C10").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Work Order").Select
Range("B12").Select
ActiveSheet.Paste
Sheets("Van 1 ").Select
Range("E10").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Work Order").Select
Range("C12").Select
ActiveSheet.Paste
Sheets("Service schedule").Select
Range("B2:C2").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Work Order").Select
Range("B11:C11").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=2, Collate:=True
Range("B2:B8").Select
---
Message posted from http://www.ExcelForum.com/