I'm a n00b and I've been searching the forums and the closest thing I can find to my problem was addressed here: Simple Macro to cut and paste based on cell value
I'm trying to have any cells in column M that are greater than 0 be cut and paste into a column 3 columns to the right of the original in the same row in the same worksheet. This code below was from the original forum
The code I've got looks like this:
It returns an error saying:
Run-time error '1004'
Paste method of Worksheet class failed
Running the macro currently only cuts the first value greater than 0 in Column M and pastes it into Column P (good!), but into the last row with a value greater than 0 from Column M (BAD). So I'm needing
1. it to do this for all cells in Column M greater than 0
2. paste it in the same row of Column P
I'm trying to have any cells in column M that are greater than 0 be cut and paste into a column 3 columns to the right of the original in the same row in the same worksheet. This code below was from the original forum
VBA Code:
Sub atest()
Dim LR As Long, i As Long
With Sheets("All")
LR = .Range("C" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With .Range("C" & i)
If .Value Like "*Time*" Then .EntireRow.Cut Destination:=Sheets("All Time").Range("C" & Rows.Count).End(xlUp).Offset(1, -2)
End With
Next i
End With
End Sub
The code I've got looks like this:
VBA Code:
Dim LR As Long, i As Long
With Sheets("Sheet1")
LR = .Range("M" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With .Range("M" & i)
If .Value > 0 Then .Cut Destination:=Sheets("Sheet1").Range("M" & Rows.Count).End(xlUp).Offset(0, 3)
ActiveSheet.Paste
End With
Next i
End With
It returns an error saying:
Run-time error '1004'
Paste method of Worksheet class failed
Running the macro currently only cuts the first value greater than 0 in Column M and pastes it into Column P (good!), but into the last row with a value greater than 0 from Column M (BAD). So I'm needing
1. it to do this for all cells in Column M greater than 0
2. paste it in the same row of Column P