Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default 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   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default 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
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
userform Enabled property behavior changes between excel 97 and 2000/3 Nicholas Dreyer Excel Programming 2 September 20th 06 05:01 AM
Odd UserForm Behavior Gene Excel Programming 8 August 4th 06 04:10 AM
ComboBox control behavior changes when BeforeUpdate event hand Rick Lowe Excel Programming 0 August 25th 04 10:13 PM
irrational problem Libby Excel Programming 0 August 17th 04 05:21 PM
Control code behavior with userform ? steve Excel Programming 0 July 30th 03 05:01 PM


All times are GMT +1. The time now is 11:26 PM.

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"