Thread: User Forms
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_7_] Bob Phillips[_7_] is offline
external usenet poster
 
Posts: 1,120
Default User Forms

Write the data to a hidden worksheet cell in the userform close event, and
restore it in the workbook_open,

In the userform

Private Sub UserForm_Terminate()
With Worksheets("formdata")
.Range("A1").Value = TextBox1.Text
.Range("A2").Value = TextBox2.Text
End With
End Sub

and in the Thisworkbook code module

Private Sub Workbook_Open()
With Worksheets("formdata")
Load UserForm1
UserForm1.TextBox1.Text = .Range("A1").Value
UserForm1.TextBox2.Text = .Range("A2").Value
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

"Gilly Hampshire" wrote in
message ...
Could some one please help. I am trying to create a user form that will
enter data into an Excel spreadsheet. I have managed to do this but I

want 2
of the text boxes to remeber what was last entered into them. I have

managed
this if I hide the form but when I close the spreadsheet and reopen the

form
has now lost the information. What can I do to prevent this happening!!!
--
Thanks

Gilly