I am running into a problem when trying to copy multiplesheets in a row in excel. The copy works if its only 1 or 2 sheets but anything over 2 copies in a row it fails, and I dont get an error.
I am using this code...
VB Code:
Set oSheet = oBook.Worksheets(oBook.Sheets(oBook.Sheets.Count).Name) lngSheetCount = oBook.Sheets.Count 'Copy inital last sheet into new sheet oExcel.ActiveWorkbook.Sheets(lngSheetCount).Copy _ After:=oExcel.ActiveWorkbook.Sheets(lngSheetCount) Set oSheet = oExcel.ActiveSheet 'Rename the worksheet oSheet.Name = Firms.Item(clc)
I was wondering if anyone else had run into this issue, I have tried placing DoEvents in some places to try to pass control back to windows so it could finish the copy but it doesnt seem to work.




Reply With Quote