Search column for string and write to cell
One example...
Paste this code in a VBA module in your workbook. Click any cell in the
column to be searched, then run the macro (Tools Macro Macros
FindText Run).
Sub FindText()
Dim c As Range, ret
Const FindThis = "zebra"
Const WriteThis = "animal"
ActiveCell.EntireColumn.Select
For Each c In Selection
ret = InStr(c, FindThis)
If (Not IsNull(ret)) And (ret 0) Then
c.Offset(0, 1).Value = WriteThis
End If
Next c
End Sub
Hope this helps,
Hutch
"Blee" wrote:
Not sure why I cannot find any code to do this, but.... I'm looking to
write a macro that would search a specific column for a string
(contains) and write a specific value to another cell in that same row
if there is a match. I.e., If column Z has a string that contains
"zebra", write "animal" to cell B of that same row. Anyone?
|