PDA

View Full Version : Solved: Find, Cut, Move & Copy issue



Phelony
05-14-2009, 05:01 AM
Hi guys :hi:

Hope you're all doing well. Once more I'm here to lay a minor annoying problem out and hope you can :help with what is most likely another silly bit of programming from me!

This little snippet of code is supposed to find the word yes in column G, cut the row and then paste it sequentially on another sheet.

It fails on the pasting part and I really can't figure out why. :bug:

NB - this works if you put copy where it says cut, but I really do need to cut and paste.

' DatamoveR Macro
'
Dim r As Long, lastrow As Long, rOut As Long
rOut = 1
lastrow = Sheets("Sheet1").range("G65536").End(xlUp).Row
For r = 1 To lastrow
If Sheets("sheet1").Cells(r, 7) Like "yes" Then
Sheets("sheet1").Rows(r).EntireRow.Cut
Sheets("sheet2").Rows(rOut).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
rOut = rOut + 1
End If
Next r

Application.CutCopyMode = False

End Sub

Thoughts gentlemen?

Thanks

Phel x

Phelony
05-14-2009, 05:38 AM
I've actually found a way to get it to work to my advantage while just copying.

However, if anyone does know why the above won't cut and paste it would be good to know. :cool:

Thanks

Phel x

Bob Phillips
05-14-2009, 05:59 AM
Dim r As Long, lastrow As Long, rOut As Long

Sheets("sheet2").Select
With Sheets("Sheet1")

rOut = 1
lastrow = .Range("G65536").End(xlUp).Row
For r = 1 To lastrow

If .Cells(r, 7) Like "yes" Then

.Rows(r).Cut
Rows(rOut).Select
ActiveSheet.Paste
.Rows(rOut).Value = .Rows(rOut).Value
rOut = rOut + 1
End If
Next r
End With


Application.CutCopyMode = False

Phelony
05-14-2009, 06:07 AM
Star, as always

x