Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Make textbox1.value default

I have a form that contains a textbox. How can I make the entered value
appear in the textbox the next time the form is opened? As in I would like to
be able to control the default value of the textbox.

Thanks
The Doctor
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Make textbox1.value default

Bob Phillips answered a similar question just now:

David,

The method that I use is a hidden worksheet. Store the values when the form
is unloaded, then retrieve them when the form is re-loaded.

There are many alternatives, use the registry, a text file, or even Excel
names, but a hidden worksheet is the simplest IMO.

Sample code

Private Sub UserForm_Initialize()
With Worksheets("SavedValues")
Me.TextBox1.Text = .Range("A1").Value
If .Range("A2").Value < "" Then
Me.ListBox1.ListIndex = .Range("A2").Value
End If
End With
End Sub

Private Sub UserForm_Terminate()
With Worksheets("SavedValues")
.Range("A1").Value = Me.TextBox1.Text
.Range("A2").Value = Me.ListBox1.ListIndex
End With

End Sub


--
HTH

Bob Phillips



--
Regards,
Tom Ogilvy

"Dr.Schwartz" wrote in message
...
I have a form that contains a textbox. How can I make the entered value
appear in the textbox the next time the form is opened? As in I would like

to
be able to control the default value of the textbox.

Thanks
The Doctor



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Make textbox1.value default

Thanks Tom and Bob, just what I was looking for.

The Doctor

"Tom Ogilvy" wrote:

Bob Phillips answered a similar question just now:

David,

The method that I use is a hidden worksheet. Store the values when the form
is unloaded, then retrieve them when the form is re-loaded.

There are many alternatives, use the registry, a text file, or even Excel
names, but a hidden worksheet is the simplest IMO.

Sample code

Private Sub UserForm_Initialize()
With Worksheets("SavedValues")
Me.TextBox1.Text = .Range("A1").Value
If .Range("A2").Value < "" Then
Me.ListBox1.ListIndex = .Range("A2").Value
End If
End With
End Sub

Private Sub UserForm_Terminate()
With Worksheets("SavedValues")
.Range("A1").Value = Me.TextBox1.Text
.Range("A2").Value = Me.ListBox1.ListIndex
End With

End Sub


--
HTH

Bob Phillips



--
Regards,
Tom Ogilvy

"Dr.Schwartz" wrote in message
...
I have a form that contains a textbox. How can I make the entered value
appear in the textbox the next time the form is opened? As in I would like

to
be able to control the default value of the textbox.

Thanks
The Doctor




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
How do I make make comment format default? delta_charm Excel Discussion (Misc queries) 1 July 8th 06 10:59 PM
TextBox1 to Label4 damorrison Excel Discussion (Misc queries) 5 March 12th 06 04:05 PM
alternative to TextBox1.Activate jose luis Excel Programming 1 June 4th 05 02:48 AM
x = textbox1.value (somethings wrong) CAA[_18_] Excel Programming 6 March 5th 04 03:24 PM
UserForm1.Textbox1.SetFocus Question Zane Greer Excel Programming 1 September 14th 03 11:59 AM


All times are GMT +1. The time now is 08:46 PM.

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"