PDA

View Full Version : Input difference words run difference macro in one textbox



ms06f
08-04-2012, 09:05 PM
When I input text only into textbox1 then run macro1,
or input numbers only into textbox1 then run macro2.

How to do it?

Thankyou very much.

mikerickson
08-04-2012, 10:25 PM
Perhaps
Dim uiInput as Variant

uiInput = Application.InputBox("Enter Something", type:=3)

Select Case TypeName(uiInput)
Case "Boolean"
Exit Sub: Rem cancel pressed
Case "String"
Call Macro1
Case Else
Call Macro2
End Select

GTO
08-04-2012, 10:30 PM
Greetings ms06f,

It is difficult to understand what exactly you are wanting to do? I presume that you want to run a different procedure based upon what the user has typed into the textbox, but at least two questions:

Where is the textbox? (i.e. - is it on a userform, or on a worksheet?)
What is the textbox's name?
After typing something into the textbox, what event is supposed to start things up? That is, do we have a button to push on the sheet/userform?

Mark

ms06f
08-05-2012, 03:51 AM
Private Sub UserForm_Initialize()
Dim uiInput As Variant
uiInput = Application.InputBox("Enter Something", Type:=3)

Select Case TypeName(uiInput)
Case "Boolean"
Exit Sub: Rem cancel pressed
Case "String"
TextBox2.Text = TextBox1
Case Else
TextBox3.Text = TextBox1
End Select
End Sub



Yes, Thankyou for your HELP.