Anaya Zeeshan
New Member
- Joined
- Nov 4, 2021
- Messages
- 33
- Office Version
- 365
- Platform
- Windows
I have written this code to cut rows from worksheet (shUpdated) based on column AB to another worksheet (ShCompleted). It is giving me this error "Paste method of worksheet class failed". here is the code:
Option Explicit
Sub Project_Completed()
Dim LastRow As Long
Dim Rng1 As Range
Dim cell As Range
LastRow = shUpdate.Range("AB" & Rows.Count).End(xlUp).Row
Set Rng1 = shUpdate.Range("AB3", shUpdate.Range("AB" & LastRow))
For Each cell In Rng1
If cell.Value = "Completed" Then
cell.EntireRow.Select
Selection.Delete Shift:=xlUp
ShCompleted.Select
Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
shUpdate.Activate
' Sheets("Completed Projects").Select
' Range("A3").Select
' ActiveSheet.Paste
End If
Next cell
End Sub
Option Explicit
Sub Project_Completed()
Dim LastRow As Long
Dim Rng1 As Range
Dim cell As Range
LastRow = shUpdate.Range("AB" & Rows.Count).End(xlUp).Row
Set Rng1 = shUpdate.Range("AB3", shUpdate.Range("AB" & LastRow))
For Each cell In Rng1
If cell.Value = "Completed" Then
cell.EntireRow.Select
Selection.Delete Shift:=xlUp
ShCompleted.Select
Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
shUpdate.Activate
' Sheets("Completed Projects").Select
' Range("A3").Select
' ActiveSheet.Paste
End If
Next cell
End Sub