View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
MCheru MCheru is offline
external usenet poster
 
Posts: 70
Default Cut Contents and Paste

That's the ticket. Thank so much for you're help!

"Per Jessen" wrote:

Hi

This should do it:

For r = LastRow To 1 Step -1
If Range("A" & r).Value = "ZRP3" Then
Range(Cells(r, "A"), Cells(r, "L")).Cut
Destination:=wsB.Range("A1").Offset(off, 0)
off=off+1
End If
Next

Regards,
Per

"MCheru" skrev i meddelelsen
...
You were right thanks for the tip. I am still having one problem though.
Although all the rows with ZRP3 are disappearing only the first line is
pasting on the new worksheet. Any thoughts?

"Per Jessen" wrote:

Thanks for your reply.

You are a victim of word wrap. The line mentioned should be a part of the
line above. To fix it remove the carriage return between this line and
the
line above.

Regards,
Per

"MCheru" skrev i meddelelsen
...
Thank you for you're help. I appreciate your feedback. The macro
appears
to
be getting hung up on this part.

Destination:=wsB.Range("A1").Offset(off, 0), but I am not sure how to
fix
it.

"Per Jessen" wrote:

Hi

Look at this:

Sub CutContentsandPaste()
Dim wsA As Worksheet
Dim wsB As Worksheet
Dim LastRow As Long
Dim off As Long

Set wsA = Worksheets("Sheet1") ' Change to suit
Set wsB = Worksheets.Add

wsA.Activate
LastRow = Range("A" & Rows.Count).End(xlUp).Row
off = 0

For r = LastRow To 1 Step -1
If Range("A" & r).Value = "ZRP3" Then
Range(Cells(r, "A"), Cells(r, "L")).Cut
Destination:=wsB.Range("A1").Offset(off, 0)
End If
Next
End Sub

Regards,
Per

"MCheru" skrev i meddelelsen
...
I am trying to create a macro that will search every cell in Column A
for
ZRP3 when it finds these contents cut the entire row it exists in up
to
column L, and paste all the rows that got copied into a new
worksheet.
This
what I have written so far but its not quite doing the job

Sub CutContentsandPaste()
Range("A1").Select
ActiveCell.FormulaR1C1[-1]= "ZRP3"
Range("A:L").Select
Selection.Cut
Sheets.Add
ActiveSheet.Paste
End Sub