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!

Problem with Find method

Status
Not open for further replies.

Stretchwickster

Programmer
Apr 30, 2001
1,746
GB
Hi people!

I wrote the following VBA code which checks the Range C4:R4 for the item selected in the ProjTitleComboBox. As I have written in the following comments - when I test this code, ProjTitleComboBox.Text contains "Administration" and so does cell "C4" therefore a match should be found but Find returns nothing!

Has anyone got any ideas as to what could be going wrong?

Code:
'In this instance ProjTitleComboBox.Text contains "Administration"
  Set duplicateProjectRange = wsBcTS.Range("C4:R4").Find(What:=ProjTitleComboBox.Text, LookIn:=xlValues)
  If Not duplicateProjectRange Is Nothing Then
    MsgBox "This project already exists on your timesheet"
  End If
  MsgBox wsBcTS.Range("C4").Value 'displays "Administration"

Your help would be much appreciated!

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
coupla suggestions
what is wsBcTs ?? is it the correct worksheet ??
Set the lookat:=
parameter as well - set to xlwhole or xlpart dependant on your needs - you may have a space at the start or end of one of the pieces of text which, if it is set to xlwhole, will not give a match
Try setting a variable = projTitlecombobox.text and put a watch on it
do the same for
wsBcTS.Range("C4").Value
to check for this....

Other then that, can't see anything wrong with the code





Rgds
Geoff
Si hoc legere scis, nimis eruditionis habes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top