Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
irrational userform/combobox behavior
This has me baffled. It's going to be hard to explain. I will
simplify it as much as possible. I have a listbox a combobox a button and a sheet. The listbox contains a list of numbers. when a number in the listbox is clicked, that number is entered into the combobox using this code: Private Sub ListBoxW_Click() UserFormDesign.ComboBoxWsections.Text = UserFormDesign.ListBoxW.Text End Sub alternatively, the number in the combobox can be changed directly with it's pull down menu. I use the following code to update a cell (sheet2-D284) in the sheet with the combobox number, each time the combobox number changes: Private Sub ComboBoxWsections_Change() Sheets("sheet2").Range("D284").Value = UserFormDesign.ComboBoxWsections.Text End Sub Up to this point, everything works successfully. Next, there is a button on the userform (the same form that contains the combo and listbox), which when clicked, runs a routine that copies the cell with the combobox value to a different cell (sheet2-C28) and does some other stuff, then it hides the userform and shows a sheet of results, including the value in the first cell I mentioned (sheet2-D284). here is the relevant code for when the button is clicked: Private Sub CommandButtonWView_Click() Call Module1.SingleW Sheet5.Select UserFormDesign.Hide Application.WindowState = xlMaximized End Sub here is the relevant code within Module1.SingleW: Sheets("sheet2").Range("C28").Value = Sheets("sheet2").Range("D284").Value here is the problem: when the value is updated via the listbox, everything works correctly. when the value is set via the combobox, the value defaults back to the last clicked listbox value. The value to cell D284 does update after changing the combobox but somehow it goes back to the previous listbox value after clicking the results button. prehaps it is the value in the listbox that is still highlighted when clicking the button. I would appreciate any help I can get on this. It's driving me crazy. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
irrational userform/combobox behavior
I think I have narrowed it down further.
the following code is being executed when the button is clicked, and I do not want it to. I want it to be executed ONLY when the listbox is clicked. Private Sub ListBoxW_Click() UserFormDesign.ComboBoxWsections.Text = UserFormDesign.ListBoxW.Text End Sub why would it be doing that? Jacob wrote: This has me baffled. It's going to be hard to explain. I will simplify it as much as possible. I have a listbox a combobox a button and a sheet. The listbox contains a list of numbers. when a number in the listbox is clicked, that number is entered into the combobox using this code: Private Sub ListBoxW_Click() UserFormDesign.ComboBoxWsections.Text = UserFormDesign.ListBoxW.Text End Sub alternatively, the number in the combobox can be changed directly with it's pull down menu. I use the following code to update a cell (sheet2-D284) in the sheet with the combobox number, each time the combobox number changes: Private Sub ComboBoxWsections_Change() Sheets("sheet2").Range("D284").Value = UserFormDesign.ComboBoxWsections.Text End Sub Up to this point, everything works successfully. Next, there is a button on the userform (the same form that contains the combo and listbox), which when clicked, runs a routine that copies the cell with the combobox value to a different cell (sheet2-C28) and does some other stuff, then it hides the userform and shows a sheet of results, including the value in the first cell I mentioned (sheet2-D284). here is the relevant code for when the button is clicked: Private Sub CommandButtonWView_Click() Call Module1.SingleW Sheet5.Select UserFormDesign.Hide Application.WindowState = xlMaximized End Sub here is the relevant code within Module1.SingleW: Sheets("sheet2").Range("C28").Value = Sheets("sheet2").Range("D284").Value here is the problem: when the value is updated via the listbox, everything works correctly. when the value is set via the combobox, the value defaults back to the last clicked listbox value. The value to cell D284 does update after changing the combobox but somehow it goes back to the previous listbox value after clicking the results button. prehaps it is the value in the listbox that is still highlighted when clicking the button. I would appreciate any help I can get on this. It's driving me crazy. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
irrational userform/combobox behavior
I can't see anything from your posted snippets; maybe post larger sections
of your code, for example everything in your button code? Keith "Jacob" wrote in message ups.com... I think I have narrowed it down further. the following code is being executed when the button is clicked, and I do not want it to. I want it to be executed ONLY when the listbox is clicked. Private Sub ListBoxW_Click() UserFormDesign.ComboBoxWsections.Text = UserFormDesign.ListBoxW.Text End Sub why would it be doing that? Jacob wrote: This has me baffled. It's going to be hard to explain. I will simplify it as much as possible. I have a listbox a combobox a button and a sheet. The listbox contains a list of numbers. when a number in the listbox is clicked, that number is entered into the combobox using this code: Private Sub ListBoxW_Click() UserFormDesign.ComboBoxWsections.Text = UserFormDesign.ListBoxW.Text End Sub alternatively, the number in the combobox can be changed directly with it's pull down menu. I use the following code to update a cell (sheet2-D284) in the sheet with the combobox number, each time the combobox number changes: Private Sub ComboBoxWsections_Change() Sheets("sheet2").Range("D284").Value = UserFormDesign.ComboBoxWsections.Text End Sub Up to this point, everything works successfully. Next, there is a button on the userform (the same form that contains the combo and listbox), which when clicked, runs a routine that copies the cell with the combobox value to a different cell (sheet2-C28) and does some other stuff, then it hides the userform and shows a sheet of results, including the value in the first cell I mentioned (sheet2-D284). here is the relevant code for when the button is clicked: Private Sub CommandButtonWView_Click() Call Module1.SingleW Sheet5.Select UserFormDesign.Hide Application.WindowState = xlMaximized End Sub here is the relevant code within Module1.SingleW: Sheets("sheet2").Range("C28").Value = Sheets("sheet2").Range("D284").Value here is the problem: when the value is updated via the listbox, everything works correctly. when the value is set via the combobox, the value defaults back to the last clicked listbox value. The value to cell D284 does update after changing the combobox but somehow it goes back to the previous listbox value after clicking the results button. prehaps it is the value in the listbox that is still highlighted when clicking the button. I would appreciate any help I can get on this. It's driving me crazy. Thanks. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
irrational userform/combobox behavior
I solved it by changing the listbox click event to a mouseup event. it
still makes no sense why the listbox click event would execute when the button was clicked, but this works fine. thanks for looking at it though, and if you have any insight as to why that might happen, please let me know. KR wrote: I can't see anything from your posted snippets; maybe post larger sections of your code, for example everything in your button code? Keith "Jacob" wrote in message ups.com... I think I have narrowed it down further. the following code is being executed when the button is clicked, and I do not want it to. I want it to be executed ONLY when the listbox is clicked. Private Sub ListBoxW_Click() UserFormDesign.ComboBoxWsections.Text = UserFormDesign.ListBoxW.Text End Sub why would it be doing that? Jacob wrote: This has me baffled. It's going to be hard to explain. I will simplify it as much as possible. I have a listbox a combobox a button and a sheet. The listbox contains a list of numbers. when a number in the listbox is clicked, that number is entered into the combobox using this code: Private Sub ListBoxW_Click() UserFormDesign.ComboBoxWsections.Text = UserFormDesign.ListBoxW.Text End Sub alternatively, the number in the combobox can be changed directly with it's pull down menu. I use the following code to update a cell (sheet2-D284) in the sheet with the combobox number, each time the combobox number changes: Private Sub ComboBoxWsections_Change() Sheets("sheet2").Range("D284").Value = UserFormDesign.ComboBoxWsections.Text End Sub Up to this point, everything works successfully. Next, there is a button on the userform (the same form that contains the combo and listbox), which when clicked, runs a routine that copies the cell with the combobox value to a different cell (sheet2-C28) and does some other stuff, then it hides the userform and shows a sheet of results, including the value in the first cell I mentioned (sheet2-D284). here is the relevant code for when the button is clicked: Private Sub CommandButtonWView_Click() Call Module1.SingleW Sheet5.Select UserFormDesign.Hide Application.WindowState = xlMaximized End Sub here is the relevant code within Module1.SingleW: Sheets("sheet2").Range("C28").Value = Sheets("sheet2").Range("D284").Value here is the problem: when the value is updated via the listbox, everything works correctly. when the value is set via the combobox, the value defaults back to the last clicked listbox value. The value to cell D284 does update after changing the combobox but somehow it goes back to the previous listbox value after clicking the results button. prehaps it is the value in the listbox that is still highlighted when clicking the button. I would appreciate any help I can get on this. It's driving me crazy. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
userform Enabled property behavior changes between excel 97 and 2000/3 | Excel Programming | |||
Odd UserForm Behavior | Excel Programming | |||
ComboBox control behavior changes when BeforeUpdate event hand | Excel Programming | |||
irrational problem | Excel Programming | |||
Control code behavior with userform ? | Excel Programming |