![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 76
|
How can I set the default value for textbox controls with VBA?
I have tried accessing the .Default property, but VBA gives an error "could not set the default property. Member not found". In case I am not being totally clear... This is what I mean by default: If you go into the forms editor in VBA and manualy enter the value for a textbox in the properties field... That will be the default when the form is run. I want to be able to do this with VBA. Thanks for any help!! |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi John,
Sheets("Sheet1").TextBox1.Value = 1000 worked for me. You can reset it in your code whenever it is needed. If this is a textbox on a UserForm, then you can set the value upon initialization or whenever the form is reset/recalled. Let us know if this works. I may have misread your question. Bye, Jay |
|
|
|
|
|
#3 | |
|
Board Regular
Join Date: Feb 2002
Posts: 76
|
Quote:
I guess I could store the filename somewhere in a worksheet than load it in during initialize... But I was hoping there was a way to change the default itself. (Like you can when you manualy edit a userform) If not... Oh well. I'll just store it in a worksheet. Thanks. |
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Another little trick is to store values in a label and just make the font the same color as the form...
Tom |
|
|
|
|
|
#5 | |
|
Board Regular
Join Date: Feb 2002
Posts: 76
|
Quote:
Me.Label1.Caption = Me.Textbox1.Value But the Label is only changed while the form is active... After it is unloaded the changes doent stick. Maybe I'm doing something wrong? |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|