Hi. I've got a problem with a sub which copies from a protected worksheet in one workbook, into another worksheet in a different workbook. I open the protected workbook with:
I then call an 'Import' sub which strips out several worksheets individually and pastes into my workbook.
It gets as far as the Selection.PasteSpecial line and gives me an 1004 error, "cell you are trying to change is protected and therefore read-only". The sheet I am pasting to is not protected at all, only the source is.
I'd also like to be able to copy the entire worksheet and not just a selection (i.e. A1:AE124). I did try this before but this also resulted in an error. Any ideas?
Steve
Code:
Workbooks.Open "filename.xls", ReadOnly
I then call an 'Import' sub which strips out several worksheets individually and pastes into my workbook.
Code:
Sub Import(AFilePrefix As String, loopCount As Integer)
'
' Import Macro
'
Dim sheetname As String
sheetname = ActiveWorkbook.Name
Application.ScreenUpdating = False
For i = 1 To 7
Windows(AFilePrefix & "Performance.xls").Activate
Sheets(dyArray(i)).Select
Range("A1:AE124").Select
Application.CutCopyMode = False
Selection.Copy
Windows(sheetname).Activate
Sheets(dyArray(i)).Select
Range("A1:AE124").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
For j = 1 To 124
Range("AF" & j).Value = dyArray(i)
Range("AG" & j).Value = j
Range("AH" & j).Value = "X"
Next j
Range("A1").Select
Next i
Sheets("Tools").Select
Range("C" & loopCount).Value = "Imported"
Range("A1").Select
Application.ScreenUpdating = True
End Sub
It gets as far as the Selection.PasteSpecial line and gives me an 1004 error, "cell you are trying to change is protected and therefore read-only". The sheet I am pasting to is not protected at all, only the source is.
I'd also like to be able to copy the entire worksheet and not just a selection (i.e. A1:AE124). I did try this before but this also resulted in an error. Any ideas?
Steve