Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locate specific values in column

Status
Not open for further replies.

polavar

Programmer
Jun 30, 2003
8
US
How to know the relative locations of cells having following values in column Q.

1) ATP
2) Glucose
3) Protein

If these values are not there in that column then I should get msgbox saying that these values are not there in the column'Q'

 
Code:
  Dim foundRange as Range
  Dim searchString as String
  ...
  searchString = "ATP"
  Set foundRange = Columns("Q").Find(What:=searchString,    LookIn:=xlValues, LookAt:=xlWhole)
  if foundRange = Nothing then
    Msgbox "Unable to find" & searchString
  else
    foundRange.Select
  end if
You can substitute the foundRange.Select line for any (Range object) property you might find useful such as foundRange.Address - have a look in the VBA help for the properties of Range.

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top