View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Copy and Paste Overlap

Adam,

The simple solution is to start your loop at row 3, since there isn't any
need to check row 2: all your code does is trying to do is move row 2 to row
2, so don't bother trying.

HTH,
Bernie
MS Excel MVP

"Adam" wrote in message
...
I have a macro that will look until it finds a 0 in
column A. Then it will copy that row to row 2. If row 2
contains a 0 in column A, I get an error. It says:

"Run-time error '1004':
This selection is not valid
There are several possible reasons:
-Copy and paste areas cannot overlap unless they're the
same size and shape.
-If you're using the Create command on the Name submenu
of the Insert menu, the row or column containing the
proposed names won't....."

Here is my code:
For n = 2 To FinalRow
If (Range("A" & n).Value) = 0 Then
Rows(n & ":" & n).Cut
Rows("2:2").Insert Shift:=xlDown
End If
Next n

Thank you