search buttons please help
Michael,
It may be worth mentioning to your boss that re-inventing the wheel
isn't normally a good idea unless there really is something
specifically different that you are trying to achieve. I doubt any
code that we could write in VBA would ever be as strong and efficient
as that which is built into the program itself. For example the code
that I posted has no error checking whatsoever. To crash it, all you
would have to do is search for something that doesn't exist and you
will see what I mean. This can of course be trapped and fixed, but I'd
like to see anyone crash the built in search box. Personally I think
that teaching people 'Ctrl+F' would be easier than running to a user's
desk every time they do something you never anticipated and break your
code.
Regards,
Ivan.
On Apr 2, 1:19*am, Ivyleaf wrote:
Hi Michael,
No, work is fine... thanks for asking :). As I said, I relly wasn't
trying to make a personal comment. I know it sounded like I was but I
was simply very puzzled and I really couldn't think of another way to
ask. I sincerely do apologise.
As for your question, the following code should give a starting point:
Private Sub CommandButton1_Click()
* * Dim SearchStr As String
* * SearchStr = TextBox1.Text
* * Cells.Find(What:=SearchStr, After:=ActiveCell, LookIn:=xlFormulas,
_
* * * * LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
* * * * MatchCase:=False, SearchFormat:=False).Activate
End Sub
This assumes you have added a form with a text box called TextBox1 and
a button called CommandButton1. If you want to use the returned range
somewhere, get rid of the ".Activate" at the end of the search bit,
and use a variable to catch the range: Set FoundRng = Cells.Find(...
Cheers,
Ivan.
On Apr 2, 12:34*am, Michael wrote:
so first of all u r not beeing rude its curiosity isnt it
second of all its database for people who dont know excel that well as i
think you do
third of all my Boss gave me that order
forth of all r u able to help me ? or should i wait for someone who knows
how to do it cuz i really need a help.
Meanwhile save ur personal comments for yourself :-) I had asked for help
not asked what i want to achieve- Are you having a bad day at work ? ;-)
Cheers,
Michael- Hide quoted text -
- Show quoted text -
|