Avatar of Jagwarman
Jagwarman
 asked on

vba to find text then copy entire row to Sheet2

I have searched EE but cannot find an answer to my question although there are variations on the theme

Can an Expert provide me with VBA code that will find text and then copy the entire row to Sheet2. There could be 10 or a thousand rows to copy.

The column I need to look in is 'F' and I need to copy entire row where either Mandatory or Voluntary is found in 'F' [there could be additional words after both of these words]

Thanks
Microsoft Excel

Avatar of undefined
Last Comment
Jagwarman

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rgonzo1971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jagwarman

ASKER
Brilliant many thanks
Jagwarman

ASKER
Rgonzo1971 is it easy to make it start in A10 when it puts the data on Sheet2?

Thanks
Rgonzo1971

pls try


Sub macro()

For Each c In Range(Range("F1"), Range("F" & Rows.Count).End(xlUp))
    If c Like "*Mandatory*" Or c Like "*Voluntary*" Then
        c.EntireRow.Copy Sheets("Sheet2").Range("A" & WorksheetFunction.Max(10, Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row + 1))
        
    End If
Next
End Sub

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Jagwarman

ASKER
That is very od it puts the first row in Row 102 the next in 10103 then 1010104 and the rest one row below each time 1010105,1010106 etc

Anyway I can simply insert rows at the start but thanks for trying.