Link to home
Create AccountLog in
Avatar of Saqib Husain
Saqib HusainFlag for Pakistan

asked on

Phonebook application - Enhacing search capabilities

I have this phonebook application developed through this TA, the latest version at

I have modified the data in this file and would like to enhance the search capability.

Currently the search looks for the string anywhere in the data field.

I would like to have a checkbox called "Whole words" which, when unchecked, works just as it does now.

When the checkbox is checked the search should look at whole words or numbers. So that ro would match Rory and not broomee. I think the delimeters for a word or number should be

There could be more but I think I can add that later.
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Saqib Husain


I wouldn't call that a Whole word match but more a beginning of word match

I agree but what I wanted was something short to write in there.

Thanks, looks good now.
HI, again, I just discovered that  the underscore is not considered a word separator. I cannot pick Chris_Bottomley  by typing B. Can you do something about it?
Yes sure, couple of options. In the userform code (line 19) you could specify "standard word boundary or underscore":
re.Pattern = "(\b|_)" & strInput ' "(^|[ ,_-])"

Open in new window

The comment there shows the alternative I mentioned earlier where you only allow the exact characters you want. Just make sure the "-" is the first or last character within the range (block quotes) because otherwise it changes the meaning to a range of characters.