aman,
If you are only looking for a match, why are you making your recordset <= TextBox1.Value instead of just = TextBox1.Value ?
What is lastrow as a typical value? maybe it is just looping very long in the "for i" loop?
Also, what is the recordcount for rs? maybe you have a LOT of records coming down?
Are you calling this macro directly, or does another macro call it? any chance the infinite loop is not caused by this macro? Also, I'd change
. I'm no expert, but I do know that depending on the cursor and lock type you may get odd results when trying to use .eof or .bof, i've had macros "freeze" when using them unless I make sure I use lock/cursor that supports it. You may want to try:
and see if that helps at all.
The code is pretty painful to read/follow without some indendation... and a workbook would help with context and seeing what is wrong.
Bookmarks