Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro that makes calculations. In these calculations an error margin
is tolerated. In the spreadsheet the user can press a button and a userform is shown. In this userform the error margin is shown in textbox. The user can change the error margin if wanted but the problem is that the change only lasts as long as the variable lives. As my macro is structured now the userform is run separately from the actual calculations i.e. any change in error margin will have no affect on the actual calculations since the variable will already be dead when the calculation starts. Is there any way of €śpermanently€ť storing the new value? What I am referring to is some form of self editing code that changes the value for the variable. The variable that I use for storing the error margin is a global variable. Here is code from the userform: Private Sub UserForm_Initialize() dblErrorMarginal = 0.00000001 TextBox1.Text = dblErrorMarginal End Sub Private Sub changeErrorMargin_Click() dblErrorMarginal = TextBox1.Text Unload Me End Sub And at the top of the Modul1 where I have the main program: Public dblErrorMarginal As Double Please help me solve this problem if it is possible. Thank you very much in advance! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Store the value of the variable in an un-used cell.
-- Gary's Student "Arne Hegefors" wrote: I have a macro that makes calculations. In these calculations an error margin is tolerated. In the spreadsheet the user can press a button and a userform is shown. In this userform the error margin is shown in textbox. The user can change the error margin if wanted but the problem is that the change only lasts as long as the variable lives. As my macro is structured now the userform is run separately from the actual calculations i.e. any change in error margin will have no affect on the actual calculations since the variable will already be dead when the calculation starts. Is there any way of €śpermanently€ť storing the new value? What I am referring to is some form of self editing code that changes the value for the variable. The variable that I use for storing the error margin is a global variable. Here is code from the userform: Private Sub UserForm_Initialize() dblErrorMarginal = 0.00000001 TextBox1.Text = dblErrorMarginal End Sub Private Sub changeErrorMargin_Click() dblErrorMarginal = TextBox1.Text Unload Me End Sub And at the top of the Modul1 where I have the main program: Public dblErrorMarginal As Double Please help me solve this problem if it is possible. Thank you very much in advance! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes I thought about that too but although it solves the problem it does not
seem like an optimal solution but I might just do that if it is not possible to fix elsewise. Thanks very much Gary's Student and give my best to Gary! "Gary''s Student" skrev: Store the value of the variable in an un-used cell. -- Gary's Student "Arne Hegefors" wrote: I have a macro that makes calculations. In these calculations an error margin is tolerated. In the spreadsheet the user can press a button and a userform is shown. In this userform the error margin is shown in textbox. The user can change the error margin if wanted but the problem is that the change only lasts as long as the variable lives. As my macro is structured now the userform is run separately from the actual calculations i.e. any change in error margin will have no affect on the actual calculations since the variable will already be dead when the calculation starts. Is there any way of €śpermanently€ť storing the new value? What I am referring to is some form of self editing code that changes the value for the variable. The variable that I use for storing the error margin is a global variable. Here is code from the userform: Private Sub UserForm_Initialize() dblErrorMarginal = 0.00000001 TextBox1.Text = dblErrorMarginal End Sub Private Sub changeErrorMargin_Click() dblErrorMarginal = TextBox1.Text Unload Me End Sub And at the top of the Modul1 where I have the main program: Public dblErrorMarginal As Double Please help me solve this problem if it is possible. Thank you very much in advance! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
:-)
-- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Arne Hegefors" wrote in message ... Yes I thought about that too but although it solves the problem it does not seem like an optimal solution but I might just do that if it is not possible to fix elsewise. Thanks very much Gary's Student and give my best to Gary! "Gary''s Student" skrev: Store the value of the variable in an un-used cell. -- Gary's Student "Arne Hegefors" wrote: I have a macro that makes calculations. In these calculations an error margin is tolerated. In the spreadsheet the user can press a button and a userform is shown. In this userform the error margin is shown in textbox. The user can change the error margin if wanted but the problem is that the change only lasts as long as the variable lives. As my macro is structured now the userform is run separately from the actual calculations i.e. any change in error margin will have no affect on the actual calculations since the variable will already be dead when the calculation starts. Is there any way of "permanently" storing the new value? What I am referring to is some form of self editing code that changes the value for the variable. The variable that I use for storing the error margin is a global variable. Here is code from the userform: Private Sub UserForm_Initialize() dblErrorMarginal = 0.00000001 TextBox1.Text = dblErrorMarginal End Sub Private Sub changeErrorMargin_Click() dblErrorMarginal = TextBox1.Text Unload Me End Sub And at the top of the Modul1 where I have the main program: Public dblErrorMarginal As Double Please help me solve this problem if it is possible. Thank you very much in advance! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Store it in a workbook name
ActiveWorkbook.Names.Add Name:="__temp", RefersTo:=Textbox1.Text retrieve it with MsgBox ActiveSheet.Evaluate(ActiveWorkbook.Names("__temp" ).RefersTo) -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Arne Hegefors" wrote in message ... I have a macro that makes calculations. In these calculations an error margin is tolerated. In the spreadsheet the user can press a button and a userform is shown. In this userform the error margin is shown in textbox. The user can change the error margin if wanted but the problem is that the change only lasts as long as the variable lives. As my macro is structured now the userform is run separately from the actual calculations i.e. any change in error margin will have no affect on the actual calculations since the variable will already be dead when the calculation starts. Is there any way of "permanently" storing the new value? What I am referring to is some form of self editing code that changes the value for the variable. The variable that I use for storing the error margin is a global variable. Here is code from the userform: Private Sub UserForm_Initialize() dblErrorMarginal = 0.00000001 TextBox1.Text = dblErrorMarginal End Sub Private Sub changeErrorMargin_Click() dblErrorMarginal = TextBox1.Text Unload Me End Sub And at the top of the Modul1 where I have the main program: Public dblErrorMarginal As Double Please help me solve this problem if it is possible. Thank you very much in advance! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how to Permanently change default font for comments | Excel Discussion (Misc queries) | |||
How do I permanently change the Microsoft Office author? | Excel Discussion (Misc queries) | |||
How do I change $ to ÂŁ permanently in Excel? | Excel Discussion (Misc queries) | |||
how do I change a cell permanently to PM from AM? | Excel Discussion (Misc queries) | |||
Permanently change CheckBox control's value use VBA | Excel Programming |