D
DTM
I am receiving the following error at the "Activesheet.paste" line i
the following code. I do not understand this because the script worke
before and now it fails almost every time. Is there another way t
paste?:
==============================
Run-time error '1004':
Paste method of Worksheet class failed
==============================
Code as follows
------------------------------------------------------
Public Sub UnprotectSheets(Worksheet As String)
Worksheets(Worksheet).Unprotect password:="password"
End Sub
------------------------------------------------------
Public Sub ProtectSheets(Worksheet As String)
Worksheets(Worksheet).Protect password:="password"
End Sub
------------------------------------------------------
Public Sub Move_Approved()
Dim R As Long
Dim LastRow As Long
Dim PasteRow As Long
Dim Selected As String
Application.EnableEvents = False
'On Error GoTo Exit_Move_Approved
Sheets("Request Purchase").Select
LastRow = ActiveSheet.Cells(Rows.Count, "J").End(xlUp).Row
If LastRow > 4 Then
For R = 5 To LastRow
If Cells(R, "J").Value <> "" Then
Selected = Selected & R & ":" & R & ","
End If
Next R
Selected = Left(Selected, Len(Selected) - 1)
Range(Selected).Select
Selection.Copy
Sheets("Approved Purchase").Select
PasteRow = ActiveSheet.Cells(Rows.Count, "J").End(xlUp).Row
1
UnprotectSheets ("Approved Purchase")
Rows(PasteRow & ":" & PasteRow).Select
ActiveSheet.Paste '****FAILS HERE*****
ProtectSheets ("Approved Purchase")
Sheets("Request Purchase").Select
UnprotectSheets ("Request Purchase")
Selection.Delete
ProtectSheets ("Request Purchase")
End If
Exit_Move_Approved:
ProtectSheets ("Request Purchase")
ProtectSheets ("Approved Purchase")
Application.EnableEvents = True
End Su
the following code. I do not understand this because the script worke
before and now it fails almost every time. Is there another way t
paste?:
==============================
Run-time error '1004':
Paste method of Worksheet class failed
==============================
Code as follows
------------------------------------------------------
Public Sub UnprotectSheets(Worksheet As String)
Worksheets(Worksheet).Unprotect password:="password"
End Sub
------------------------------------------------------
Public Sub ProtectSheets(Worksheet As String)
Worksheets(Worksheet).Protect password:="password"
End Sub
------------------------------------------------------
Public Sub Move_Approved()
Dim R As Long
Dim LastRow As Long
Dim PasteRow As Long
Dim Selected As String
Application.EnableEvents = False
'On Error GoTo Exit_Move_Approved
Sheets("Request Purchase").Select
LastRow = ActiveSheet.Cells(Rows.Count, "J").End(xlUp).Row
If LastRow > 4 Then
For R = 5 To LastRow
If Cells(R, "J").Value <> "" Then
Selected = Selected & R & ":" & R & ","
End If
Next R
Selected = Left(Selected, Len(Selected) - 1)
Range(Selected).Select
Selection.Copy
Sheets("Approved Purchase").Select
PasteRow = ActiveSheet.Cells(Rows.Count, "J").End(xlUp).Row
1
UnprotectSheets ("Approved Purchase")
Rows(PasteRow & ":" & PasteRow).Select
ActiveSheet.Paste '****FAILS HERE*****
ProtectSheets ("Approved Purchase")
Sheets("Request Purchase").Select
UnprotectSheets ("Request Purchase")
Selection.Delete
ProtectSheets ("Request Purchase")
End If
Exit_Move_Approved:
ProtectSheets ("Request Purchase")
ProtectSheets ("Approved Purchase")
Application.EnableEvents = True
End Su