![]() |
Cut and Paste Error
My program is searching for a row that has the following
characteristics. When it finds the row, it pastes the row into the third line. However, if the row was already in the third line, I get an error. The problem is that I have no idea where the line is going to show up, so I can't just start at the forth line. Thank you. i=3 For n = 3 To FinalRow If Not ((Range("A" & n).Value) = "") And (Range("B" & n).Value) = 1 Then Rows(n & ":" & n).Cut Rows(i & ":" & i).Insert Shift:=xlDown End If Next n |
Cut and Paste Error
You could try:
Sub test() i = 3 On Error Resume Next For n = 3 To FinalRow If Not ((Range("A" & n).Value) = "") And _ (Range("B" & n).Value) = 1 Then Rows(n & ":" & n).Cut Rows(i & ":" & i).Insert Shift:=xlDown End If Next n On Error GoTo 0 End Sub Regards Trevor wrote in message ... My program is searching for a row that has the following characteristics. When it finds the row, it pastes the row into the third line. However, if the row was already in the third line, I get an error. The problem is that I have no idea where the line is going to show up, so I can't just start at the forth line. Thank you. i=3 For n = 3 To FinalRow If Not ((Range("A" & n).Value) = "") And (Range("B" & n).Value) = 1 Then Rows(n & ":" & n).Cut Rows(i & ":" & i).Insert Shift:=xlDown End If Next n |
All times are GMT +1. The time now is 01:47 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com