Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default TextBox Coding Help

Sorry but I am just a newbie to Visual basic.

I have a worksheet (Sheet 1) into which I have created a
User form with 2 text boxes (TextBox1, TextBox2) and 1
command button (CommandButton1).

In the results of these boxes need to go into specific
cells. Eg. TextBox1 into A1 and TextBox2 into A3 when the
command button is clicked.

So... found in help the coding below that I placed into
declarations of Sheet 1 in the file called Test.xlt. It
does not display the form when I create a new document
based on Test.xlt and I do not know how to get the coding
to place the results in a cell. If you could also direct
me to either a good beginner VBA site for Excel or a good
book for a rank beginner, I would be grateful!

Private Sub UserForm_Initialize()
TextBox1.Text = "From TextBox1!"
TextBox2.Text = "Hello "

CommandButton1.Caption = "Cut and Paste"
CommandButton1.AutoSize = True
End Sub

Private Sub CommandButton1_Click()
TextBox2.SelStart = 0
TextBox2.SelLength = TextBox2.TextLength
TextBox2.Cut

TextBox1.SetFocus
TextBox1.SelStart = 0

TextBox1.Paste
TextBox2.SelStart = 0
End Sub


So how do I modify the above??? Help!

Thanks!
Shauna
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default TextBox Coding Help

I don't have time to get into your question but this should be valuable
for one aspect you mentioned:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default TextBox Coding Help

OK, with a little persistence I got it working when I am
viewing the userform and I click Run Sub, but I am not
sure how to get it to display the UserForm when your
File menu, New, and choose the template - generating a new
workbook?

Private Sub UserForm_Initialize()
Load UserForm1
'Position 2 is center of screen, postion 3 top left
corner
UserForm1.StartUpPosition = 2

UserForm1.Show

CommandButton1.Caption = "OK"

End Sub

Private Sub CommandButton1_Click()
'Insert text from textboxes into cells
With ActiveDocument
Worksheets("Sheet1").Range("A1") = TextBox1.Text
Worksheets("Sheet1").Range("A3") = TextBox2.Text

End With

UserForm1.Hide

End Sub

Thanks!

Shauna

-----Original Message-----
Sorry but I am just a newbie to Visual basic.

I have a worksheet (Sheet 1) into which I have created a
User form with 2 text boxes (TextBox1, TextBox2) and 1
command button (CommandButton1).

In the results of these boxes need to go into specific
cells. Eg. TextBox1 into A1 and TextBox2 into A3 when the
command button is clicked.

So... found in help the coding below that I placed into
declarations of Sheet 1 in the file called Test.xlt. It
does not display the form when I create a new document
based on Test.xlt and I do not know how to get the coding
to place the results in a cell. If you could also direct
me to either a good beginner VBA site for Excel or a good
book for a rank beginner, I would be grateful!

Private Sub UserForm_Initialize()
TextBox1.Text = "From TextBox1!"
TextBox2.Text = "Hello "

CommandButton1.Caption = "Cut and Paste"
CommandButton1.AutoSize = True
End Sub

Private Sub CommandButton1_Click()
TextBox2.SelStart = 0
TextBox2.SelLength = TextBox2.TextLength
TextBox2.Cut

TextBox1.SetFocus
TextBox1.SelStart = 0

TextBox1.Paste
TextBox2.SelStart = 0
End Sub


So how do I modify the above??? Help!

Thanks!
Shauna
.

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
Calculate Textbox value based on another textbox value.doc Tdungate Excel Discussion (Misc queries) 1 February 12th 09 07:11 PM
Calculate Textbox value based on another textbox value Tdungate Excel Discussion (Misc queries) 0 February 12th 09 07:03 PM
How to fix the coding? Eric Excel Worksheet Functions 0 February 26th 08 03:38 AM
coding Hardy Excel Discussion (Misc queries) 1 February 22nd 05 04:58 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 06:07 AM.

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

About Us

"It's about Microsoft Excel"