Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Anyone know why this doesn't work ?
There's a Form with 2 checkboxes and these Click events Private Sub chkK1_Click() chkK1 = True chkA1 = False Application.StatusBar = "chkK1" End Sub Private Sub chkA1_Click() chkA1 = True chkK1 = False Application.StatusBar = "chkA1" End Sub The intent is, as chkK1 is ticked, chkA1 will bceome unticked and Vice versa. But it doesn't work! How can it NOT work ??? I've also tried .Value = and .Caption = and removed' = True' (in case that was automatic), but still no go. What am I doing wrong? At least the Application.StatusBar message works ! Thanks - Kirk |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Anyone know why this doesn't work ?
kirkm wrote:
There's a Form with 2 checkboxes and these Click events Private Sub chkK1_Click() chkK1 = True chkA1 = False Application.StatusBar = "chkK1" End Sub Private Sub chkA1_Click() chkA1 = True chkK1 = False Application.StatusBar = "chkA1" End Sub The intent is, as chkK1 is ticked, chkA1 will bceome unticked and Vice versa. But it doesn't work! How can it NOT work ??? I've also tried .Value = and .Caption = and removed' = True' (in case that was automatic), but still no go. What am I doing wrong? At least the Application.StatusBar message works ! Thanks - Kirk So what happens? I would expect, by reading this code, that you could only untick a box by ticking the other one. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Anyone know why this doesn't work ?
On Wed, 29 Jul 2009 18:24:22 -0400, smartin
wrote: So what happens? I would expect, by reading this code, that you could only untick a box by ticking the other one. That's exactly what I want, i.e you can only choose one of them. But what does happen is odd. Try it out. I think Excels applying a built in toggle which won't disable. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Anyone know why this doesn't work ?
kirkm wrote:
On Wed, 29 Jul 2009 18:24:22 -0400, smartin wrote: So what happens? I would expect, by reading this code, that you could only untick a box by ticking the other one. That's exactly what I want, i.e you can only choose one of them. But what does happen is odd. Try it out. I think Excels applying a built in toggle which won't disable. Works as expected. I click on box 1 and, regardless of its previous state, it becomes or remains selected, box 2 becomes or remains unselected, and status bar reads box 1. Similar for box 2. And, box 1 and box 2 always have opposite state. What are you trying to do? If you want mutually exclusive selections, options buttons are the control of choice. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Anyone know why this doesn't work ?
On Wed, 29 Jul 2009 22:40:21 -0400, smartin
wrote: Works as expected. I click on box 1 and, regardless of its previous state, it becomes or remains selected, box 2 becomes or remains unselected, and status bar reads box 1. Similar for box 2. And, box 1 and box 2 always have opposite state. Weird. That sounds like what I wanted it to do.... but doesn't. The first click on Box1 select 1 with Box2 is unselected. Then click Box2 and nothing happens. (Except the status bar message) What are you trying to do? If you want mutually exclusive selections, options buttons are the control of choice. Yes, that works. But check boxes were preferred. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Anyone know why this doesn't work ?
On Wed, 29 Jul 2009 21:26:43 +1200, kirkm wrote:
There's a Form with 2 checkboxes and these Click events Private Sub chkK1_Click() chkK1 = True chkA1 = False Application.StatusBar = "chkK1" End Sub Private Sub chkA1_Click() chkA1 = True chkK1 = False Application.StatusBar = "chkA1" End Sub The intent is, as chkK1 is ticked, chkA1 will bceome unticked and Vice versa. But it doesn't work! How can it NOT work ??? I've also tried .Value = and .Caption = and removed' = True' (in case that was automatic), but still no go. What am I doing wrong? At least the Application.StatusBar message works ! Thanks - Kirk A problem with your code seems to be that the manipulation of the checkbox value from inside the code also fires the click event. You thereby get into an "infinite loop" that is only interrupted because some internal event buffer (or what it might be called) gets overloaded. Put this statement as the first statement of any of you click procedures and you will see from the behaviour of cell A1 what I mean Worksheets("Sheet1").Cells(1, 1) = Worksheets("Sheet1").Cells(1, 1) + 1 In my case, Excel 2007, cell A1 is increased to 284 before Excel "gives up". I suggest you use radiobuttons instead of checkboxes is you want the mutual exlusive property. If you insist on using checkboxes, you will have to try to find the "source" of the click event to see if it is a mouse click or from user code. I don't know if that is possible in VBA. Hope this helps / Lars-Åke |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
flash object dont work in my excel work sheet | Excel Discussion (Misc queries) | |||
HOW TO MAKE A LIST OF WORK SHEET IN WORK BOOK IN EXCEL 2007 | Excel Programming | |||
If I have a work sheet protected and try to run a macro to hide rows or columns it won't work. Correct? | Excel Programming | |||
Counting dates in multiple work sheets and work books | Excel Discussion (Misc queries) | |||
Is there away to keep "auto save" from jumping to the first work sheet in the work book? | New Users to Excel |