Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save value on form


Excel 2003 w/Visual Basic 6.3

At a point in my macro I calculate a value, and then assign that valu
to a text box on another form. My questions a

1) Can that value be saved on the form so that the next time I run th
macro the value in the text box is already stored?

2) Can the value in the text box be formatted, e.g. to display only
decimal places

Thank

--
scantor14
-----------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...fo&userid=1476
View this thread: http://www.excelforum.com/showthread.php?threadid=38647

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Save value on form

You need to store the value from the txtbox on a sheet somewhere. The sheet
can be hidden from the user. You can then use code similar to this to
retrieve the value...

Private Sub UserForm_Initialize()
TextBox1.Text = Format(Sheet1.Range("A1").Value, "#,##0.00")
End Sub

Where you have stored the text box value in sheet1 cell A1
--
HTH...

Jim Thomlinson


"scantor145" wrote:


Excel 2003 w/Visual Basic 6.3

At a point in my macro I calculate a value, and then assign that value
to a text box on another form. My questions a

1) Can that value be saved on the form so that the next time I run the
macro the value in the text box is already stored?

2) Can the value in the text box be formatted, e.g. to display only 2
decimal places

Thanks


--
scantor145
------------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=386473


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save value on form


1) The easiest way I know how is to write the value to a cell. Then whe
the userform opens again, set the "controlsource" of the textBox to th
value in the cell that you previously stored the value in.

RANGE(\"A1\").VALUE = TEXTBOX1.VALU
'After closed and reopened

*TextBox1.Value = Range("A1") *
'OR
*TextBox1.ControlSource = Range("A1")*

With this method, if changes are made to the value, it can creat
problems sometimes

Or something similar depending on how your user form is set u

--
speyr
-----------------------------------------------------------------------
speyry's Profile: http://www.excelforum.com/member.php...fo&userid=2512
View this thread: http://www.excelforum.com/showthread.php?threadid=38647

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Save value on form


"scantor145"

Excel 2003 w/Visual Basic 6.3


At a point in my macro I calculate a value, and then assign that value
to a text box on another form. My questions a


1) Can that value be saved on the form so that the next time I run the
macro the value in the text box is already stored?


2) Can the value in the text box be formatted, e.g. to display only 2
decimal places


Well, at least in Excel you can use Round(). For example:

TextBox1.Text = Round(variable,4)

"variable" will then be displayed as 4-decimal place figure in TextBox1.
You might also embellish the display, for example:

TextBox1.Text = "Execution time: " & Round(variable,4) & " seconds."

---Fausto



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Save value on form

In your code your might insert a Name and set it = to the value.
Than refer to the name to set the textbox.

recorded code in Excel 2000
ActiveWorkbook.Names.Add Name:="Myvalue", RefersToR1C1:="=13"


--
steveB

Remove "AYN" from email to respond
"speyry" wrote in
message ...

1) The easiest way I know how is to write the value to a cell. Then when
the userform opens again, set the "controlsource" of the textBox to the
value in the cell that you previously stored the value in.

RANGE(\"A1\").VALUE = TEXTBOX1.VALUE
'After closed and reopened

*TextBox1.Value = Range("A1") *
'OR
*TextBox1.ControlSource = Range("A1")*

With this method, if changes are made to the value, it can create
problems sometimes

Or something similar depending on how your user form is set up


--
speyry
------------------------------------------------------------------------
speyry's Profile:
http://www.excelforum.com/member.php...o&userid=25128
View this thread: http://www.excelforum.com/showthread...hreadid=386473



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
save form naso Excel Discussion (Misc queries) 2 November 24th 07 11:02 PM
Button in Excel that will save the form? Jason Excel Worksheet Functions 1 October 27th 05 04:55 PM
Using Macro to save form to file DB Excel Programming 1 June 11th 05 01:45 AM
Save from form input Sam Excel Programming 2 December 22nd 04 03:38 PM
Save data in template from a form. Please Help! Myriam Excel Programming 2 July 20th 04 03:02 AM


All times are GMT +1. The time now is 08:57 AM.

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"