How do I search for a word and add text to a cell if found?

  • Thread starter Thread starter Bie1997
  • Start date Start date
B

Bie1997

How would I search each row for specific text and return custom text to the
beginning of the row the search text was found in?
 
Substitute actual text for Specific text and Custom text. Also, assumed the
worksheet to be 1, if not change that too.

Sub SpefcText()
Dim c As Range
myVar = "Specific Text"
Set c = Worksheets(1).Cells.Find(myVar, LookIn:=xlValues)
If Not c Is Nothing Then
Range("A" & c.Row) = "Custom Text"
End If
End Sub
 

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

Back
Top