I am trying to Move ( Archive) a row of data in Excel, based on a Value ( Date) being in a cell.
I want the entire row removed from the sheet where it resides ( "Master" and placed in another sheet ("Archived" within the same workbook, if the cell in Column "EA" has a date in it.
The blank row should be deleted from ("MASTER" and Inserted into ("ARCHIVED"
What I have ,and I am trying I get an error stating an Object is required at the ***Starred* ** Line of code below. And I am not getting it ! Is there an Easier way of doing this ?
Application.ScreenUpdating = False
ReturnSheet = ActiveSheet.Name
Range("EA6".Select ' Select Completed Date Column
Set AreaRange = ActiveCell.CurrentRegion
Set MyRange = Intersect(ActiveCell.EntireColumn, AreaRange)
' Define Area that Matches Select Cell Value
x = Date
For Each Cell In MyRange
If Cell.Value = x Then
If i = 0 Then
Set NewRange = Cell.EntireRow
Else
Set NewRange = Union(NewRange, Cell.EntireRow)
End If
i = i + 1
End If
Next
' Copy & Paste
Sheets("Archived".Select
Range("A6".Select
NewRange.Copy ' ****This is where it errors stating Object required ****
Selection.Insert Shift:=xlDown
Application.CutCopyMode = xlCut
Range("A6".Select
NewRange.Delete Shift:=xlUp
Sheets(ReturnSheet).Select
Application.ScreenUpdating = True
Sheets("MASTER".Select
Range("AE6".Select
End Sub
I want the entire row removed from the sheet where it resides ( "Master" and placed in another sheet ("Archived" within the same workbook, if the cell in Column "EA" has a date in it.
The blank row should be deleted from ("MASTER" and Inserted into ("ARCHIVED"
What I have ,and I am trying I get an error stating an Object is required at the ***Starred* ** Line of code below. And I am not getting it ! Is there an Easier way of doing this ?
Application.ScreenUpdating = False
ReturnSheet = ActiveSheet.Name
Range("EA6".Select ' Select Completed Date Column
Set AreaRange = ActiveCell.CurrentRegion
Set MyRange = Intersect(ActiveCell.EntireColumn, AreaRange)
' Define Area that Matches Select Cell Value
x = Date
For Each Cell In MyRange
If Cell.Value = x Then
If i = 0 Then
Set NewRange = Cell.EntireRow
Else
Set NewRange = Union(NewRange, Cell.EntireRow)
End If
i = i + 1
End If
Next
' Copy & Paste
Sheets("Archived".Select
Range("A6".Select
NewRange.Copy ' ****This is where it errors stating Object required ****
Selection.Insert Shift:=xlDown
Application.CutCopyMode = xlCut
Range("A6".Select
NewRange.Delete Shift:=xlUp
Sheets(ReturnSheet).Select
Application.ScreenUpdating = True
Sheets("MASTER".Select
Range("AE6".Select
End Sub