Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MsgBox and User Input

Hello,
I am currently creating a spreadsheet to automate a few tasks for
my users. Currently I have a command button in place, when this is
clicked, a msgbox pops up and asks for user input. What I need to
happen is the user input to be declared as a variable. Once it is
declared, probably with IF statements, I need to reference a msgbox,
depending on what the user inputs, I need to direct to the
corresponding msgbox. Example, the user inputs the two-letter
abbreviation for a state. Using that abbrev, I need to return a msgbox
with the corresponding text.

Any ideas as to how I can do this? If you could get me started with
the code, or point me in the direction that would be great.

For more explanation e-mail .
Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default MsgBox and User Input

Do
res = InputBox("Enter two character State Abbreviation")
if len(trim(res)) = 0 then exit sub
While len(trim(res)) < 2

res1 = Application.vlookup(res,Range("Table1"),2,False)
if not iserror(res1) then
msgbox "Abbr: " & res & " state is: " & res1
Else
msgbox "Bad Abbr: " & res
End if

on a worksheet put the 50 abbreviations in left column and corresponding
state name in right column. Name the table Table1.

--
regards,
Tom Ogilvy

"Terrin" wrote in message
om...
Hello,
I am currently creating a spreadsheet to automate a few tasks for
my users. Currently I have a command button in place, when this is
clicked, a msgbox pops up and asks for user input. What I need to
happen is the user input to be declared as a variable. Once it is
declared, probably with IF statements, I need to reference a msgbox,
depending on what the user inputs, I need to direct to the
corresponding msgbox. Example, the user inputs the two-letter
abbreviation for a state. Using that abbrev, I need to return a msgbox
with the corresponding text.

Any ideas as to how I can do this? If you could get me started with
the code, or point me in the direction that would be great.

For more explanation e-mail .
Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default MsgBox and User Input

Terrin,

For the input declare a variable
Dim myvar
set it "as String" but be ready to trap any errors.

Keep in mind that any InputBox will return a String even
if the user enters a number.

Than
myvar = InputBox("Prompt", "Title", "Default", xpos, ypos)
Prompt should be your instruction
Title should be what ever you want to call it
Default can be nothing, a given string, or another variable

than
MsgBox("My state is " & myvar)

see if this helps...
--
sb
"Terrin" wrote in message
om...
Hello,
I am currently creating a spreadsheet to automate a few tasks for
my users. Currently I have a command button in place, when this is
clicked, a msgbox pops up and asks for user input. What I need to
happen is the user input to be declared as a variable. Once it is
declared, probably with IF statements, I need to reference a msgbox,
depending on what the user inputs, I need to direct to the
corresponding msgbox. Example, the user inputs the two-letter
abbreviation for a state. Using that abbrev, I need to return a msgbox
with the corresponding text.

Any ideas as to how I can do this? If you could get me started with
the code, or point me in the direction that would be great.

For more explanation e-mail .
Thanks.



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
Prompt user for input and utilize that input ninner Excel Worksheet Functions 2 March 28th 07 09:44 PM
Have user input converted to uppercase in same cell as input? Shannonn New Users to Excel 1 June 20th 06 03:19 AM
Wait for user to change data after msgbox ???? CanadianTrev Excel Discussion (Misc queries) 1 June 18th 05 08:27 PM
Get User Input Gord Dibben[_3_] Excel Programming 0 July 23rd 03 10:48 PM
msgbox prompt when user selects data from combo box Tom Ogilvy Excel Programming 5 July 11th 03 09:24 PM


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

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

About Us

"It's about Microsoft Excel"