JamesDSM50328
Technical User
I need some assistance with a Sheet(Array(---)).copy. I have a worksheet that contains the names of the other worksheets if indicated will be copied to a new workbook.
the code loops through and creates an array for the sheets that it needs to copy, but it errors on the line
Error: -2147417848(80010108) Method 'COPY' of 'Sheets' failed.
the code loops through and creates an array for the sheets that it needs to copy, but it errors on the line
Code:
origwb.Sheets(Array(sheetArray)).Copy
Error: -2147417848(80010108) Method 'COPY' of 'Sheets' failed.
Code:
...
set origwb=thisworkbook
For a = tr To lr
If IsEmpty(origwb.Sheets("CoverPage").Cells(a, c2)) = False Then
For b = ts To ls
sheetNames = sheetNames & origwb.Sheets("CoverPage").Cells(a, c1).Value & " " & origwb.Sheets("CoverPage").Cells(b, s1).Value & ","
Next b
sheetNames = Mid(sheetNames, 1, Len(sheetNames) - 1)
sheetArray = Split(CStr(sheetNames), ",")
origwb.Sheets(Array(sheetArray)).Copy
set destwb = ActiveWorkbook
sheetNames=""
End If
Next a