Popup box for data entry...

T

Taylor Francis

This request will probably betray the fact that I'm relatively new to
Excel...

I need a button on a page (I can do that) that pops up a box that asks
for a value. After you enter the value in the box, it puts it in a cell
on that page...

Can anyone help with this???

Thanks!
Taylor
 
G

Gord Dibben

Taylor

Here are a couple of macros.

Sub Test()
'allows numeric value
Num = InputBox("Enter a number")
If Num <> "" And IsNumeric(Num) Then
Range("A1").Value = Num
End If
End Sub

Sub Test22()
'allows string value
txtstr = InputBox("Enter a string")
If txtstr <> "" And Not IsNumeric(txtstr) Then
Range("A1").Value = txtstr
End If
End Sub

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and Insert>Module. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run the macro by going to Tool>Macro>Macros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben MS Excel MVP

This request will probably betray the fact that I'm relatively new to
Excel...

I need a button on a page (I can do that) that pops up a box that asks
for a value. After you enter the value in the box, it puts it in a cell
on that page...

Can anyone help with this???

Thanks!
Taylor

Gord Dibben MS Excel MVP
 
D

Dave Peterson

You can add a button from the Forms toolbar (view|toolbars to see it).

Then assign this macro to the button:

Option Explicit
Sub testme()
Dim Resp As String

Resp = InputBox(Prompt:="What's the frequency, Kenny?")

If Resp = "" Then
'do nothing
Else
ActiveCell.Value = Resp
End If

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Top