cut and paste row

kenpcli

Board Regular
Joined
Oct 24, 2017
Messages
129
Is there a way to look down column C and remove the row and paste to the bottom if a certain name appears? ie if any cell in column C has "Totals for SELF PAY", it would cut the row and place it at the bottom and keep going down the work sheet?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
How about
Code:
Sub SelfPay()

   Dim Ar As Areas
   Dim Rng As Range
   
   With Columns(3)
      .Replace "Totals For SELF PAY", True, xlWhole, , False, , False, False
      Set Ar = .SpecialCells(xlConstants, xlLogical).Areas
      .Replace True, "Totals For SELF PAY", xlWhole, , False, , False, False
   End With
   For Each Rng In Ar
      Rng.EntireRow.Copy Range("[COLOR=#ff0000]B[/COLOR]" & Rows.Count).End(xlUp).Offset(1, -1)
      Rng.EntireRow.Delete
   Next Rng
End Sub
This uses col B to find the last used rows, change if needed
 
Upvote 0
How about
Code:
Sub SelfPay()

   Dim Ar As Areas
   Dim Rng As Range
   
   With Columns(3)
      .Replace "Totals For SELF PAY", True, xlWhole, , False, , False, False
      Set Ar = .SpecialCells(xlConstants, xlLogical).Areas
      .Replace True, "Totals For SELF PAY", xlWhole, , False, , False, False
   End With
   For Each Rng In Ar
      Rng.EntireRow.Copy Range("[COLOR=#ff0000]B[/COLOR]" & Rows.Count).End(xlUp).Offset(1, -1)
      Rng.EntireRow.Delete
   Next Rng
End Sub
This uses col B to find the last used rows, change if needed


Thank you, worked like a charm!
 
Upvote 0
Glad to help & thanks for the feedback

PS
You do not need to quote the posts all the time, it messes up the thread.
As a rough rule of thumb
If you are replying to the previous post no quote is needed
If you are replying to an older post, only quote what is needed.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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