Link to home
Start Free TrialLog in
Avatar of 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]

Avatar of Rgonzo1971

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jagwarman


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

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
End Sub

Open in new window

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.