View Full Version : Making a textbox display a default value
As above, I have tried several methods, I want a default number to appear in several textboxes, therefore It wont breake some calculation, thanks.
Bob Phillips
01-25-2007, 02:14 PM
Defaukted from where? On a worksheet? If so
Private Sub Userform_Activate()
With Me
.Textbox1.Text = Worksheets("Sheet1").Range("A1").Value
End With
End Sub
Erm, I have no idea what you are talking about lol, when a user opens a userform, I want several textboxes to display '1'
Sorry about not being clear
CBrine
01-25-2007, 02:35 PM
bopo,
xld's code is what you are looking for. Just open the form in design mode, double click on the form(not a control). This will open the code window for the form, and paste his code there. Now when ever the form opens textbox1's text will be defaulted. His does default the value to a sheet range value but that easy's to change.
Private Sub Userform_Activate()
With Me
.Textbox1.Text = 1
End With
End Sub
HTH
Cal
PS-You will need to make sure that the textbox name in your code matches the property name for the textbox's you added to your form.
lucas
01-25-2007, 06:53 PM
I like this one that I picked up from Tommy:
Private Sub UserForm_Initialize()
Me.TextBox1.Text = Me.Caption
Me.TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.