Find syntax

G

Guest

Hi all

I have code that works fine to search through a worksheet row by row, locate
a string anywhere in a row and, if found, copy that entire row to a different
worksheet:

For r = firstRow To lastRow
Set c = Rows(r).Find("M123")
If Not c Is Nothing Then
Rows(r).Copy
Sheets("SubData").Activate
Range("A65000").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
Range("A65000").End(xlUp).Offset(0, 0).PasteSpecial (xlPasteFormats)
Sheets("AllData").Activate
End If
Next r

However, I need to amend this so the search for a string is only carried out
on one particular column of each row (column K). I've tried all sorts of
permutations of the find syntax without success. Can anyone help please?

Many thanks
Sue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top