Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
CheckBox does not save value
I have the following code
Private Sub CheckBox1_Click() If Me.CheckBox1.Value = True Then Me.TextBox10.Value = Worksheets("Sheet4").Range("E9") Else Me.TextBox10.Value = 0 End If End Sub The problem I am having is that when I close the UserForm, the values in the textbox do not save. It seems to default to random number, in this case 74!!?? Can any one hepl? -- Tdp |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
CheckBox does not save value
So why close the form. Just hide it...
userform1.hide or me.hide -- HTH... Jim Thomlinson "Tdp" wrote: I have the following code Private Sub CheckBox1_Click() If Me.CheckBox1.Value = True Then Me.TextBox10.Value = Worksheets("Sheet4").Range("E9") Else Me.TextBox10.Value = 0 End If End Sub The problem I am having is that when I close the UserForm, the values in the textbox do not save. It seems to default to random number, in this case 74!!?? Can any one hepl? -- Tdp |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
CheckBox does not save value
Brilliant Jim.
So simple.......did'nt think of that. Many thanks -- Tdp "Jim Thomlinson" wrote: So why close the form. Just hide it... userform1.hide or me.hide -- HTH... Jim Thomlinson "Tdp" wrote: I have the following code Private Sub CheckBox1_Click() If Me.CheckBox1.Value = True Then Me.TextBox10.Value = Worksheets("Sheet4").Range("E9") Else Me.TextBox10.Value = 0 End If End Sub The problem I am having is that when I close the UserForm, the values in the textbox do not save. It seems to default to random number, in this case 74!!?? Can any one hepl? -- Tdp |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
CheckBox does not save value
Spoke too soon.
Iv added a bitton to hide the form, but I close the folder and open it again it does'nt save the values. Still reverts to the value of 74? -- Tdp "Tdp" wrote: Brilliant Jim. So simple.......did'nt think of that. Many thanks -- Tdp "Jim Thomlinson" wrote: So why close the form. Just hide it... userform1.hide or me.hide -- HTH... Jim Thomlinson "Tdp" wrote: I have the following code Private Sub CheckBox1_Click() If Me.CheckBox1.Value = True Then Me.TextBox10.Value = Worksheets("Sheet4").Range("E9") Else Me.TextBox10.Value = 0 End If End Sub The problem I am having is that when I close the UserForm, the values in the textbox do not save. It seems to default to random number, in this case 74!!?? Can any one hepl? -- Tdp |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
CheckBox does not save value
Hi,
If you weren't closing the file you could store the value by defining a global variable, which would survive until you closed the spreadsheet. However, the easiest way if you are going to close the file is to store the value in a cell in the spreadsheet: Sheet1!A1=Me.TextBox10 (don't need the Value argument) Now to get that value back into the textbox add the following code to the user form: Private Sub UserForm_Initialize() Me.TextBox10 = Sheets("Sheet1").Range("A1") End Sub A recommendation - give your user form controls names such as txtDate. -- Thanks, Shane Devenshire "Tdp" wrote: Spoke too soon. Iv added a bitton to hide the form, but I close the folder and open it again it does'nt save the values. Still reverts to the value of 74? -- Tdp "Tdp" wrote: Brilliant Jim. So simple.......did'nt think of that. Many thanks -- Tdp "Jim Thomlinson" wrote: So why close the form. Just hide it... userform1.hide or me.hide -- HTH... Jim Thomlinson "Tdp" wrote: I have the following code Private Sub CheckBox1_Click() If Me.CheckBox1.Value = True Then Me.TextBox10.Value = Worksheets("Sheet4").Range("E9") Else Me.TextBox10.Value = 0 End If End Sub The problem I am having is that when I close the UserForm, the values in the textbox do not save. It seems to default to random number, in this case 74!!?? Can any one hepl? -- Tdp |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
CheckBox does not save value
Thanks Shane,
I worked out now. Did something the same as you but my codes are alittle longer but does the job. I'v used: Me.TextBox10.Value = Worksheets("Sheet4").Range("E19").Value Worksheets("Sheet4").Range("E19") = TextBox10.Value Seems to work ok! -- Tdp "ShaneDevenshire" wrote: Hi, If you weren't closing the file you could store the value by defining a global variable, which would survive until you closed the spreadsheet. However, the easiest way if you are going to close the file is to store the value in a cell in the spreadsheet: Sheet1!A1=Me.TextBox10 (don't need the Value argument) Now to get that value back into the textbox add the following code to the user form: Private Sub UserForm_Initialize() Me.TextBox10 = Sheets("Sheet1").Range("A1") End Sub A recommendation - give your user form controls names such as txtDate. -- Thanks, Shane Devenshire "Tdp" wrote: Spoke too soon. Iv added a bitton to hide the form, but I close the folder and open it again it does'nt save the values. Still reverts to the value of 74? -- Tdp "Tdp" wrote: Brilliant Jim. So simple.......did'nt think of that. Many thanks -- Tdp "Jim Thomlinson" wrote: So why close the form. Just hide it... userform1.hide or me.hide -- HTH... Jim Thomlinson "Tdp" wrote: I have the following code Private Sub CheckBox1_Click() If Me.CheckBox1.Value = True Then Me.TextBox10.Value = Worksheets("Sheet4").Range("E9") Else Me.TextBox10.Value = 0 End If End Sub The problem I am having is that when I close the UserForm, the values in the textbox do not save. It seems to default to random number, in this case 74!!?? Can any one hepl? -- Tdp |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
checkbox | Excel Discussion (Misc queries) | |||
How to have Checkbox A uncheck with checked Checkbox B | Excel Discussion (Misc queries) | |||
checkBox help!!! | Excel Discussion (Misc queries) | |||
checkbox? | Excel Worksheet Functions | |||
Checkbox!! | Excel Discussion (Misc queries) |