View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Copying a worksheet from a different file into existing (VB-6/VBA/

Hi Mike

You can save your one sheet workbook as a template
And use code like this to add the sheet in every workbook you want
Sheets.Add Type:=Application.TemplatesPat*h & "\xxxxx.xlt"

Or open the workbook with the sheet you want to copy and copy the sheet to the active workbook

Sub test()
Dim Wb1 As Workbook
Dim Wb2 As Workbook
Application.ScreenUpdating = False
Set Wb1 = ActiveWorkbook
Set Wb2 = Workbooks.Open("C:\data\ron.xls")
Wb2.Sheets("Sheet1").copy _
after:=Wb1.Sheets(Wb1.Sheets.Count)
Wb2.Close False
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Mike" wrote in message ...
Hi! I have a spreadsheet which has one worksheet. I need to programmatically
add it to another spreadsheet. I see some samples on how to add a new sheet,
but not the existing. Everything I do comes up with some HRESULTS error.

Any idea/sample/url is greatly appreciated.

Thank you,

--Mike