MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Find command with macro doesn't work


Posted by Pasi Vartiainen on May 23, 2000 4:14 AM

I have one excel sheet, which is common help for two separated files. When using this help with 1st file, it works perfectly. But now I am trying to make it work with second file, and i am running all the time same error:
Excel's FIND command don't find any of searched texts. Macro is quite long, and most of it is just errorhandlers, so here is only the separated find function, which is called from Sub:

Function findb(what)
Columns("B:B").Select
On Error GoTo line450
Selection.Find(what:=what, After:=ActiveCell, LookIn:= _xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _SearchDirection:=xlNext, MatchCase:=False).Activate
findb = ActiveCell.Row
Rows(findb).Activate
a = MsgBox("You can get back to Pricebook by pressing Ctrl-B", vbInformation, "Useful information")
findb = "yes"
GoTo line460
line450:
findb = "no"
line460:
Exit Function
End Function

Function returns "yes" or "no" depending if it has found searched text. Search term's max lenght is 8 char's, it is cut using command Left(what, 8)
I have tried every option of find, but it doesn't find searched text sting. I have retyped text's many times in both in file which text is searched and in file whre these help texts are, but it doesn't help.

Now I am wondering if this FIND function depends on formating of cell? ..If it depend, I am in lot's of trouble, becourse each file cells are formated differently in order to make them look good and clear.

So, if someone does know what is wrong, or can give me hint to make thing in different way, I'd be pleased.

Many thank for possible help
Pasi Vartianen


Posted by Pasi Vartiainen on May 23, 2000 4:53 AM

just worked it out, sorry

I just worked it out, search was corect, answer was in one errorhandler in sub. Sorry about bothering.

br.
Pasi Vartiainen