Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA- Get user input, search the for match, output to text file
Dear Board
Hi I am a newbie in VBA for Excel. I was given a programming task by my lecturer and my head is breaking over this. I have with me now a server log(.txt file) that is huge (abt 16MB). I am suppose to search the file based on user's input and output the result back into a text file. The server log file contains about 10 fields, saparated by tab. I have managed to run and record the macro to import the text file into Excel. Now each field has a column and there are about 60000 rows of data. I am thinking of using a form with a text field for user to enter the search criteria/value and a button for them to click to initiate the search. My major problem now is I don't know how to collect the user's input and perform the search nor output the search result back to a new text file. Please help! My project is going to be due soon. Thanks so much! --- Message posted from http://www.ExcelForum.com/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA- Get user input, search the for match, output to text file
I made a phone list. I added a userform with a textbox and two command
buttons. One to start the search, the other to cancel. After that I inserted this code into the start command button click event: 'sets up error handler On Error GoTo errorhandler 'disable screeen flickering Application.ScreenUpdating = False 'set up range to search Range("b1:ag53").Select 'sets the find option to match the userform-textbox to the range Selection.Find(What:=UserForm1.TextBox1.Text, After:=ActiveCell, LookIn:=xlValues, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False).Activate 'unloads the search form Unload UserForm1 'Message Box tells user what the name and phone number is MsgBox "The phone number for " & ActiveCell & "is " & _ ActiveCell.Offset(1, 0) Cells(1, 1).Select Exit Sub 'show message box if match not found errorhandler: MsgBox "Name not found! Please check spelling or enter a new " & _ "name.", vbOKOnly, "Name not found" 'load find form for new entry UserForm1.TextBox1.SetFocus You will need to change the range to your range and change the message output to show what you found. The rest should be okay for you use. Good luck. "gnileo " wrote in message ... Dear Board Hi I am a newbie in VBA for Excel. I was given a programming task by my lecturer and my head is breaking over this. I have with me now a server log(.txt file) that is huge (abt 16MB). I am suppose to search the file based on user's input and output the result back into a text file. The server log file contains about 10 fields, saparated by tab. I have managed to run and record the macro to import the text file into Excel. Now each field has a column and there are about 60000 rows of data. I am thinking of using a form with a text field for user to enter the search criteria/value and a button for them to click to initiate the search. My major problem now is I don't know how to collect the user's input and perform the search nor output the search result back to a new text file. Please help! My project is going to be due soon. Thanks so much! --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Creating Tabbed Delimited Text File - Need help with blankcell output | Excel Discussion (Misc queries) | |||
inverse of the column function? i.e. input a number, output thecorresponding column text label | Excel Worksheet Functions | |||
Opening a file with User Input | Excel Discussion (Misc queries) | |||
How to get User input from Userform Text box | Excel Programming | |||
User Input File Name | Excel Programming |