Select range dependant on cell values

Sleepylea

New Member
Joined
Jan 26, 2015
Messages
8
I am trying to write some code which cycles through a single worksheet looking for trigger words, then copy and paste a range of data to the end of the sheet. I have searched the whole of the internet, and this isn't really covered. I have tried to Frankenstein some coding, but my skills are a little rusty, it looks quite clunky and falls over, and tbh I'm stabbing in the dark. Anyone fancy the (probably not much of a) challenge?

So, what I need it to do is this:

*Scan column "A" looking for a trigger word "Car".
*Set as the start range as this location -1 to include the headings.
*Then, find the next instance of "Call", this would then set the end of the range to be copied -1, as "Call" signifies the headings
* the trigger words are only in column "A", and the data needs to be copied up to column J (10)
*Cut the area and paste to the end of the data on the sheet.
*Delete the now empty rows in the middle of the workbook

This is to be repeated for three different trigger words.

Any help and pointers you can provide would be so appreciated. Do let me know if you need any more information, happy to provide.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
How about
Code:
Sub CutNPaste()
   Dim i As Long
   Dim fnd1 As Range
   Dim fnd2 As Range
   Dim Ary As Variant
   
   Ary = Array("Car", "Truck", "Bike")
   For i = 0 To UBound(Ary)
      Set fnd1 = Range("A:A").Find(Ary(i), , , xlWhole, , , False, , False)
      If Not fnd1 Is Nothing Then
         Set fnd2 = Range("A:A").Find("Call", fnd1, , xlWhole, , , False, , False)
         If Not fnd2 Is Nothing Then
            Range(fnd1.Offset(-1), fnd2.Offset(-1)).EntireRow.Cut Range("A" & Rows.Count).End(xlUp).Offset(1)
         End If
      End If
   Next i
   Range("A:A").SpecialCells(xlBlanks).EntireRow.Delete
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,040
Messages
6,122,806
Members
449,095
Latest member
m_smith_solihull

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