MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

VBA - Excel (Search Command)

  Asked By: Adelina    Date: Jan 04    Category: MS Office    Views: 1709

need help in the coding of a search
command, I have some data on the spread sheet and need the search
command to read from the form and locate and highlight the particular
entry...on the spread sheet, Can you pliz help me with this coding?



1 Answer Found

Answer #1    Answered By: Bobbie Gonzalez     Answered On: Jan 04

Suppose you want to search  for the word "test" in a worksheet containing
several words in each cell then this code will search for the word "test"
starting from the first cell and highlight  it with a yellow color.

Sub SearchText()

Cells.Find(What:="test", After:=ActiveCell, LookIn:=xlValues).Activate
ActiveCell.Interior.ColorIndex = 6

End sub

This is just the tip of the iceberg as a lot can be done like multiple
searches and so on.

This code can be tied to a button which you can keep on your worksheet. As you
press this button the text will get highlighted by itself.

Didn't find what you were looking for? Find more on VBA - Excel (Search Command) Or get search suggestion and latest updates.