![]() |
|
![]() ![]() ![]() |
General Talk About Anything | |
![]() |
![]() |
![]() ![]() |
Author | Message | |
![]() Total Mods: 14 Joined: June/29/2006 Posts: 1224 |
||
As our final in my Excel "support" class, we're building an address book. My part in the whole clusterfuck is to write the code for the "Search" button. I really suck at this crap. Can anyone help? I'd go into more details, but before typing my ass off, I thought I'd see if anyone was around who had the know-how. :)
|
||
![]() |
||
Total Mods: 15 Joined: August/17/2011 Posts: 321 |
||
Been a while (couple of years since my last "Excel Master" class certification, had to go back to my books and do a bit of searching myself. Hope this helps. :) The following code should be placed in the click procedure of your 'Find' Command Button (in this case it is called Find Button). When the button is pressed, the text that is present in a text box on your worksheet (in this case TextBox1) will be found. If the text does not exist on the worksheet, then an error message is displayed. Private Sub FindButton_Click() Dim strFindWhat As String strFindWhat = TextBox1.Text On Error GoTo ErrorMessage Cells.Find(What:=strFindWhat, After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False).Select Exit Sub ErrorMessage: MsgBox ("The data you are searching for does not exist") End Sub Edited by TR_966 - April/10/2012 at 2:03pm |
||
![]() |
||
![]() Total Mods: 14 Joined: June/29/2006 Posts: 1224 |
||
We're making an address book of sorts. One sheet has places to click on radio buttons to specify what to search on a different sheet for. Last name, first name, etc. For instance, if someone chose to search by first name, and they just entered the letters ro in the text box, I need it to search all of the column that the first names are in, and find the letters ro. Someone else is working on the part of the code that selects the names that have those letters in them, and puts them in a field that the user will be able to choose which 'ro' they want. Like, it'll return results like Rosco, Robert, Bronson, etc. Make sense?
Can I pick your brain some more? My email is cbgarrison@gmail.com
|
||
![]() |
||
Total Mods: 15 Joined: August/17/2011 Posts: 321 |
||
I don't know how much help I 'll be, but I will try. I used Excel daily in my old job and not at all in my new one (last three years). I have done something similar to what you are talking about, I am just trying to remember. My e-mail is TR_966@hotmail.com Mention Bmod in the subject so I will open. What year Excel are you using? Mine was 2003, but not that much has changed.
|
||
![]() |
||
Total Mods: 15 Joined: August/17/2011 Posts: 321 |
||
function that search for value http://www.teacherclick.com/excel2003/a_4_5_1.htm
|
||
![]() |
||
![]() ![]() |
||
Forum Jump |
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |