ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying Worksheet to Another Open Workbook (https://www.excelbanter.com/excel-programming/310046-re-copying-worksheet-another-open-workbook.html)

[email protected]

Copying Worksheet to Another Open Workbook
 
Hi my post must not have gone through last night....

I finally go things to work...
Here is a simplified version:

Sub MyRoutine()
Dim wsh As Object
Dim fs As Object
Dim DesktopPath As String
Dim fname As String
Dim fStr As String
Dim arr As Variant
Dim wb As Workbook
Redim arr(1)
'arr represents my array of file names
arr(1) = "mynewfile.xls"
Set wsh = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
DesktopPath = wsh.SpecialFolders.Item("Desktop")
DirString = DesktopPath & "\MyNewFolder"
fstr = arr(1)
fname = DirString & "\" & fstr
Workbooks.add
Set wb = ActiveWorkbook
wb.SaveAs(fstr)
Workbooks("Myfirstworkbook.xls").Worksheets("mycop ysheet").Copy _
After:=Workbooks(fstr).Sheets(1)
..
..
..
..
End Sub

Thanks for your help. It might have been the .Close False although I
thought that meant that it shouldn't close it, maybe it means don't ask
something? or it could have been the xlWBATWorksheet that someone else
gave me. Doesn't seem needed anyway.



All times are GMT +1. The time now is 02:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com