Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move Row Based On Cell

Status
Not open for further replies.

CurtR

Programmer
Aug 9, 2000
66
US
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
 
Move your
Code:
NewRange.Copy
two lines up and replace it with this:
Code:
NewRange.Copy(Sheets("Archived").Range("A6"))
I think that'll work for you. You shouldn't have to select the destination sheet or range outside of the copy function. ----------------------------------------
If you are reading this, then you have read too far... :p

lightwarrior@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top