English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

3 answers

Use an inputbox in your code

Example:
InputBox Function Example
This example shows various ways to use the InputBox function to prompt the user to enter a value. If the x and y positions are omitted, the dialog box is automatically centered for the respective axes. The variable MyValue contains the value entered by the user if the user clicks OK or presses the ENTER key . If the user clicks Cancel, a zero-length string is returned.

Dim Message, Title, Default, MyValue
Message = "Enter a value between 1 and 3" ' Set prompt.
Title = "InputBox Demo" ' Set title.
Default = "1" ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)

' Use Helpfile and context. The Help button is added automatically.
MyValue = InputBox(Message, Title, , , , "DEMO.HLP", 10)

' Display dialog box at position 100, 100.
MyValue = InputBox(Message, Title, Default, 100, 100)

2006-06-21 15:57:56 · answer #1 · answered by O Caçador 6 · 0 0

There are several ways that you can do it. You can use a message box or input box. You can also use a form. With a form you can use many methods: a text box, a drop-down combo box, a list box, a date picker, a rich text box, etc. You can also enter the data into a cell or have the macro loop through a range of cells. It all depends on how simple or complex you want to make the macro. I definitely recommend adding an On Error GoTo statement so your macro doesn't crash or lock up your computer if you make a mistake in writing your macro, especially if you are writing a more complex macro.

I write a lot of Excel macros for work. It really helps to reduce the amount of time it takes to evaluate a lot of the data that I have to evaluate.

2006-06-28 10:00:56 · answer #2 · answered by devilishblueyes 7 · 0 0

OR
You can type the info in a cell and let the macro read it
use ...
Sheet1.range("A1").value

XLMan

2006-06-24 06:28:11 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers