Check part of cell for data

G

Guest

I need to check the cells in a column to see if any of the cells contain
certain data. For example:

Apple Pie
Apple and Berry Cobbler
Berry Jam
Apple Jam

I would need to be able to run the macro to check if the cell contained
Berry to then list each cell that fit the criteria. I've got my Loop to run
through the column and transfer the data to another column but need to code
for checking within each cell. Any help would be great. Thanks!
 
B

ben77

Try something along the line of:

Sub berry()
Dim strToFind
strToFind = "berry"
For r = 1 To 4
If InStr(1, Cells(r, 1), strToFind, vbTextCompare) > 0 Then Cells(r, 3)
= Cells(r, 1)
Next r
End Sub

This assumes the list is in column 1 and the cell contents needs
copying to column 3.
 

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