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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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