TTom
Well-known Member
- Joined
- Jan 19, 2005
- Messages
- 518
This is my very first posting on Mr Excel, so bear with me.
I am a VBA beginner, but a quick learner.
1) I created UserForm1, I open with a Button in Sheet1 using
UserForm1.Show
With no other code in this macro.
2) I created a textbox in UserForm1, named: Username
3) I created a button in UserForm1, named OKButton , its unfinished code:
****
Private Sub OKButton_Click()
' Make sure Sheet1 is active
Sheets("Sheet1").Activate
'
' ?? Code to place the text typed in textbox to Range("A1") ??
'
' Clear the controls for next entry
' Got code below from a snippet on Mr. Excel
'
Username.Text = ""
OptionUnknown = True
TextName.SetFocus
' Close the User Form, can reopen with command button
Unload UserForm1
End Sub
****
Once I show UserForm1 via button in Sheet1 I see the textbox and the OK button - Good.
But, I can not enter data into the textbox, Its as if it is a locked cell - Bad.
When I try the OK button it runs the code until it hits the Username.Text = "" code. Actually, if I type in 'Username.' in the editor, my dropdown list does not show 'Text' as an choice after the period following the texbox name. Thus, if I try: Username.Text = "" or Range("A1") = Username.Text the use of Username .Text seems acceptable to VBA.
NOTE: I have no sub nor private sub for Username textbox.
I don't know much about onfocus, etc. If you show an example be clear when you are being literal vs. replace this word with ... your code here.
Actually, I also need the textbox entry (on OK) to be assigned as a string variable that will then immediately autorun in a macro named Find_N() in Module 1. (ie: I need to know how to call macro and place textbox entry as a string variable.)
Hints on that may reduce some followups.
You can email me along with post.
Working late tonight - Thanks, TTom
I am a VBA beginner, but a quick learner.
1) I created UserForm1, I open with a Button in Sheet1 using
UserForm1.Show
With no other code in this macro.
2) I created a textbox in UserForm1, named: Username
3) I created a button in UserForm1, named OKButton , its unfinished code:
****
Private Sub OKButton_Click()
' Make sure Sheet1 is active
Sheets("Sheet1").Activate
'
' ?? Code to place the text typed in textbox to Range("A1") ??
'
' Clear the controls for next entry
' Got code below from a snippet on Mr. Excel
'
Username.Text = ""
OptionUnknown = True
TextName.SetFocus
' Close the User Form, can reopen with command button
Unload UserForm1
End Sub
****
Once I show UserForm1 via button in Sheet1 I see the textbox and the OK button - Good.
But, I can not enter data into the textbox, Its as if it is a locked cell - Bad.
When I try the OK button it runs the code until it hits the Username.Text = "" code. Actually, if I type in 'Username.' in the editor, my dropdown list does not show 'Text' as an choice after the period following the texbox name. Thus, if I try: Username.Text = "" or Range("A1") = Username.Text the use of Username .Text seems acceptable to VBA.
NOTE: I have no sub nor private sub for Username textbox.
I don't know much about onfocus, etc. If you show an example be clear when you are being literal vs. replace this word with ... your code here.
Actually, I also need the textbox entry (on OK) to be assigned as a string variable that will then immediately autorun in a macro named Find_N() in Module 1. (ie: I need to know how to call macro and place textbox entry as a string variable.)
Hints on that may reduce some followups.
You can email me along with post.
Working late tonight - Thanks, TTom