LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Copying Worksheet to Another Open Workbook

No - and I just changed my code to match what you gave me still same
error.
The idea behind this code is that I'm comparing two arrays and pulling
out information
from both - if they match, then I need a new workbook and it needs to
have a worksheet
from the file with the code in it copied and moved into the new
workbook.

Here's a more complete set:

Sub MySubroutine()
Dim wsh As Object
Dim fs As Object
Dim DesktopPath As String
Dim DirString As String
Dim wb As Workbook
Set wsh = CreateObject("Wscript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
DesktopPath = wsh.SpecialFolders.item("Desktop")
DirString = DesktopPath & "\Mynewfolder"
If UBound(item1and2)*Ubound(item3) 0 Then
If Not fs.FolderExists(DirString) Then
fs.CreateFolder DirString
End If
Application.ScreenUpdating = False
Match = 0
Newitem1 = 1
Newitem2 = 1
Newitem3 = 1
For i = 1 to UBound(myfullArray,1)
For j = 1 to UBound(myselectionsArray)
If Left(myfullArray(i,1),2) & Mid(myfullArray(i,1),4,6) =
myselectionsArray(j) Then
Match = 1
If Newitem1 = 1 Then
fStr = filenamelist(Mid(myfullarry(i,1),1,2)-10) & ".xls"
fname = DirString & "\" fStr
Workbooks.Add xlWBATWorksheet
Set wb = ActiveWorkbook
With wb
..SaveAs fname
..Close False
End With
Workbooks("Myfile.xls").Worksheets("MyWorksheet"). Copy
After:=Workbooks(fStr).Sheets(1)
Workbooks(fStr).Activate
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
..
..
..
more code

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying worksheet to another workbook Dig Excel Worksheet Functions 3 October 30th 08 09:01 PM
Copying a worksheet to another workbook Dutch Excel Discussion (Misc queries) 6 August 10th 07 05:01 PM
Copying A Worksheet From Each Open Workbook to an new Workbook carl Excel Worksheet Functions 1 January 3rd 06 05:37 PM
Copying Worksheet to Another Open Workbook [email protected] Excel Programming 2 September 15th 04 01:32 AM
Copying Worksheet to Another Open Workbook [email protected] Excel Programming 2 September 15th 04 01:30 AM


All times are GMT +1. The time now is 12:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"