View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default VBA moving a worksheet to another Workbook

Try:-

Sub surface()
Workbooks("Book1").Sheets("Sheet2").Move
After:=Workbooks("OverTime.xls").Sheets(3)
End Sub

Change workbook and sheet names to suit, these just happened to be 2 that I
had open.

Mike

"KenY" wrote:

Using a macro, I can easily move a worksheet within a workbook using the line

worksheets("KY").move after:=worksheets(worksheets.count)

However, when I try to move the sheet to another workbook using the line
below (where tab_name is a text variable), I get a subscript out of range
error. Can anyone spot my silly mistake?

Workbooks("BV_Analysis_array_4.xls").Worksheets(ta b_name).Move
befo=Workbooks("BVInf_10x_consolidator.xls").Wo rksheets(Worksheets.Count)

Thanks
--
KenY