Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Creating Tabbed Delimited Text File - Need help with blankcell output dza7 Excel Discussion (Misc queries) 3 November 5th 09 04:55 PM
inverse of the column function? i.e. input a number, output thecorresponding column text label Brotherharry Excel Worksheet Functions 19 February 14th 09 12:37 AM
Opening a file with User Input [email protected] Excel Discussion (Misc queries) 3 March 28th 07 03:00 AM
How to get User input from Userform Text box K[_3_] Excel Programming 1 September 9th 03 10:08 PM
User Input File Name kem Excel Programming 2 July 14th 03 10:23 PM


All times are GMT +1. The time now is 06:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"