Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Copy and Paste Overlap

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Copy and Paste or Paste Special between Excel Workbooks wllee Excel Discussion (Misc queries) 5 April 29th 23 03:43 AM
how copy formula that contains ranges so ranges do not overlap Patty Excel Worksheet Functions 1 November 20th 08 04:15 PM
Copy; Paste; Paste Special are disabled Mack Neff[_3_] Excel Discussion (Misc queries) 0 April 28th 08 06:29 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
I cannot paste from one workbook to another. Copy works, paste do. JimmyMc Excel Discussion (Misc queries) 1 June 10th 05 03:54 PM


All times are GMT +1. The time now is 01:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"