Copying row if it includes a certain word?

SpeedyKevin

New Member
Joined
Apr 26, 2019
Messages
17
Hello all!

Trying to use this macro (listed below) to copy rows (that include a certain word) to another sheet. As it is, it will only copy over the specified range of rows if the cell has "video" but id like it to copy it if it has "video" + any other comments that may be in the cell. Is that possible?






Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim Lastrowr As Long
Sheets("Task List Template").Activate
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Lastrowr = Sheets("Task List Template2").Cells(Rows.Count, "C").End(xlUp).Row
For i = 1 To Lastrow
If Cells(i, "D").Value = "video" Then
Cells(i, 1).Resize(, 8).Copy Sheets("Task List Template2").Cells(5, 2)
Lastrowr = Lastrowr + 1
End If
Next
Application.ScreenUpdating = True
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try replacing this:

= "video"

with this:

Like "*video*"
 
Upvote 0
Try replacing this:

= "video"

with this:

Like "*video*"

Alright I think my macro is screwed up somewhere in this area. Its only copying one row with video in it.

The rows I'd like the search to start from is Row 7, columns A-H

Sheets("Task List Template").Activate
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Lastrowr = Sheets("sheet3").Cells(Rows.Count, "C").End(xlUp).Row
For i = 7 To Lastrow
 
Upvote 0
make these changes

Code:
Sub test_copy()
    Application.ScreenUpdating = False
    Dim i As Long
    Dim Lastrow As Long
    Dim Lastrowr As Long
    Sheets("Task List Template").Activate
    Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
    Lastrowr = Sheets("Task List Template2").Cells(Rows.Count, [COLOR=#ff0000]"D"[/COLOR]).End(xlUp).Row
    For i = [COLOR=#ff0000]7[/COLOR] To Lastrow
        If [COLOR=#ff0000]LCase[/COLOR](Cells(i, "D").Value) Like[COLOR=#ff0000] "*" & "video" & "*"[/COLOR] Then
            Cells(i, 1).Resize(, 8).Copy Sheets("Task List Template2").Cells([COLOR=#ff0000]Lastrowr[/COLOR], 2)
            Lastrowr = Lastrowr + 1
        End If
    Next
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

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