Cut and paste cells

eznsd

New Member
Joined
Oct 29, 2015
Messages
42
I have the following code which is giving me a " Method'Range' of object'_Global failed" error. It fails on the line with the first instance of Range("A:O" & i)

The purpose of this macro is to search thru column "L". If a cell is empty, cut the data in my Range("A:O"), paste the data at the end of the data field, delete the row, and so on.

Any help would be appreciated! I love this site!


Code:
    Dim i As Long
    Dim LastRow As Long
    Dim LR As Long
    Sheets("DK").Activate
    
    LastRow = Cells(Rows.Count, "C").End(xlUp).Row
    LR = LastRow + 5
    
    For i = 3 To LastRow
        If Range("L" & i).Value = ("") Then
            Range("A:O" & i).Cut Destination:=Range("A" & LR)
            Range("A:O" & i).EntireRow.Delete
            Range("A" & LR).Select
            Range("A" & LR).PasteSpecial xlPasteAll
            LR = LR + 1
        End If
    Next i
    
    Range("A" & LastRow + 4).Value = "Parts not able to be processed."
    Range("A" & LastRow + 4).HorizontalAlignment = xlLeft
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,215,379
Messages
6,124,610
Members
449,174
Latest member
ExcelfromGermany

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top