Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copying worksheet to another workbook | Excel Worksheet Functions | |||
Copying a worksheet to another workbook | Excel Discussion (Misc queries) | |||
Copying A Worksheet From Each Open Workbook to an new Workbook | Excel Worksheet Functions | |||
Copying Worksheet to Another Open Workbook | Excel Programming | |||
Copying Worksheet to Another Open Workbook | Excel Programming |