#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default User Forms

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default User Forms

Same concept as Chandra but if you're writing the entries in the textboxes
to a worksheet (and presumably saving it) then in the userform's initialize
event you can write code to reverse the process. That is, write the cell
contents to the textboxes.

--
Jim
"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


  #3   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default User Forms

Essentially the same suggestion as several of the above - but how about
using a rangeless named range?

Check the Excel help item titled "Creat a name to represent a formula or a
constant"

In your VBA code, you can store the value with something line

Range("TxtBoxA").Value = me.TxtBoxA.Text

and upon opening your form, you can retrieve it with

me.TxtBoxA.Text = Range("TxtBoxA").Value

Less chance of the casual user "helpfully" changing a worksheet cell for
you...

James Cox

"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



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
New to User Forms Stacy New Users to Excel 2 July 30th 08 04:26 PM
User Forms Joanne New Users to Excel 18 July 5th 07 12:42 AM
user forms Obi-Wan Kenobi Excel Discussion (Misc queries) 0 March 21st 06 08:28 PM
User forms Scott Excel Programming 4 April 18th 04 06:22 PM
User forms in VBA Dick Kusleika Excel Programming 0 September 29th 03 05:55 PM


All times are GMT +1. The time now is 10:29 AM.

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

About Us

"It's about Microsoft Excel"