Cutting and Pasting Range Based on Text in Column to the Left

FrenchCelt

Board Regular
Joined
May 22, 2018
Messages
214
Office Version
  1. 365
Platform
  1. Windows
(Continuing off my previous thread that has been solved, this is my next step) I need to code my macro to look for 4STOP or 3STOP in Row 3 and then cut all data in the next column and paste in Row 16 of the column where the 4STOP/3STOP is located.

For example, I have a 4STOP in Column D. I need to then cut E1:E13 and paste in D16 and then move on to the next 4STOP/3STOP and repeat.

Any suggestions?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
See if this will work for you.

VBA Code:
Sub t()
Dim fn As Range, adr As String
    With ActiveSheet
        Set fn = .UsedRange.Find("3STOP", , xlValues, xlWhole)
            If Not fn Is Nothing Then
                adr = fn.Address
                Do
                    Intersect(.UsedRange.Offset(1), Columns(fn.Column + 1)).Cut .Cells(Rows.Count, fn.Column).End(xlUp)(2)
                    Set fn = .UsedRange.FindNext(fn)
                Loop While fn.Address <> adr
                Set fn = Nothing
            End If
        Set fn = .UsedRange.Find("4Stop", , xlValues, xlWhole)
            If Not fn Is Nothing Then
                adr = fn.Address
                Do
                    Intersect(.UsedRange.Offset(1), Columns(fn.Column + 1)).Cut .Cells(Rows.Count, fn.Column).End(xlUp)(2)
                    Set fn = .UsedRange.FindNext(fn)
                Loop While fn.Address <> adr
            End If
            Set fn = Nothing
    End With
End Sub
 
Upvote 0
Thanks for the response! In principle this worked almost exactly as I wanted, but in the interim while waiting for a response I made some formatting changes to the sheet and now I need the data from Rows 1-14 to be cut and pasted into Row 17 of the previous column. I also need the column where the data was cut to be deleted as part of this process. Also I noticed that the data from Row 1 wasn't being included in the cut/paste.
 
Upvote 0
Thanks for the response! In principle this worked almost exactly as I wanted, but in the interim while waiting for a response I made some formatting changes to the sheet and now I need the data from Rows 1-14 to be cut and pasted into Row 17 of the previous column. I also need the column where the data was cut to be deleted as part of this process. Also I noticed that the data from Row 1 wasn't being included in the cut/paste.
according to forum guidelines, changing the parameters of the original post will require you to start a new thread.
Regards, JLG
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,841
Members
449,051
Latest member
excelquestion515

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