Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Checkbox behaving strangely

I have a strange problem with the following code

'When Checkbox 61 is true, all checkboxes are tru
'Checkbox 61 is Select All of Cycle_Type Tabl

Private Sub CheckBox61_Click(
If CheckBox61.Value = True The
CheckBox41.Value = Tru
CheckBox42.Value = Tru
CheckBox43.Value = Tru
CheckBox44.Value = Tru
CheckBox45.Value = Tru
CheckBox46.Value = Tru
CheckBox47.Value = Tru
CheckBox48.Value = Tru
CheckBox49.Value = Tru
CheckBox50.Value = Tru
CheckBox51.Value = Tru
CheckBox52.Value = Tru
CheckBox53.Value = Tru
CheckBox54.Value = Tru
CheckBox55.Value = Tru
CheckBox56.Value = Tru
CheckBox57.Value = Tru
CheckBox58.Value = Tru
CheckBox59.Value = Tru
CheckBox60.Value = Tru
Els
CheckBox41.Value = Fals
CheckBox42.Value = Fals
CheckBox43.Value = Fals
CheckBox44.Value = Fals
CheckBox45.Value = Fals
CheckBox46.Value = Fals
CheckBox47.Value = Fals
CheckBox48.Value = Fals
CheckBox49.Value = Fals
CheckBox50.Value = Fals
CheckBox51.Value = Fals
CheckBox52.Value = Fals
CheckBox53.Value = Fals
CheckBox54.Value = Fals
CheckBox55.Value = Fals
CheckBox56.Value = Fals
CheckBox57.Value = Fals
CheckBox58.Value = Fals
CheckBox59.Value = Fals
CheckBox60.Value = Fals
End I

End Su

Wehn I select CheckBox61, all but Checkbox41 and Checkbox61 are selected. No matter how many times I click on CheckBox61, it does not get selected UNTIL I seperately select CheckBox41. Then I am able to select CheckBox61. Now if de-select CheckBox61, all the checkboxes are cleared
Why is this happening? I have done the same things thrice before, but there its working fine. Please help
TI
Shilps
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Checkbox behaving strangely

Private Sub CheckBox61_Click()
dim i as long ' index

for i= 41 to 60
controls("checkbox" & i).Value = checkbox61.Value
Next

End Sub

Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
I have a strange problem with the following code:

'When Checkbox 61 is true, all checkboxes are true
'Checkbox 61 is Select All of Cycle_Type Table

Private Sub CheckBox61_Click()
If CheckBox61.Value = True Then
CheckBox41.Value = True
CheckBox42.Value = True
CheckBox43.Value = True
CheckBox44.Value = True
CheckBox45.Value = True
CheckBox46.Value = True
CheckBox47.Value = True
CheckBox48.Value = True
CheckBox49.Value = True
CheckBox50.Value = True
CheckBox51.Value = True
CheckBox52.Value = True
CheckBox53.Value = True
CheckBox54.Value = True
CheckBox55.Value = True
CheckBox56.Value = True
CheckBox57.Value = True
CheckBox58.Value = True
CheckBox59.Value = True
CheckBox60.Value = True
Else
CheckBox41.Value = False
CheckBox42.Value = False
CheckBox43.Value = False
CheckBox44.Value = False
CheckBox45.Value = False
CheckBox46.Value = False
CheckBox47.Value = False
CheckBox48.Value = False
CheckBox49.Value = False
CheckBox50.Value = False
CheckBox51.Value = False
CheckBox52.Value = False
CheckBox53.Value = False
CheckBox54.Value = False
CheckBox55.Value = False
CheckBox56.Value = False
CheckBox57.Value = False
CheckBox58.Value = False
CheckBox59.Value = False
CheckBox60.Value = False
End If

End Sub

Wehn I select CheckBox61, all but Checkbox41 and

Checkbox61 are selected. No matter how many times I click
on CheckBox61, it does not get selected UNTIL I
seperately select CheckBox41. Then I am able to select
CheckBox61. Now if de-select CheckBox61, all the
checkboxes are cleared.
Why is this happening? I have done the same things

thrice before, but there its working fine. Please help.
TIH
Shilps
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Checkbox behaving strangely

Its giving Syntax Error
When I changed the code t
dim i as long ' inde

for i= 41 to 6
("checkbox" & Cstr(i)).Value = checkbox61.Valu
Nex
It is giving Compile Error
Expected: Line number or label or statement or end of statemen

When I change the code t

Controls(("Checkbox" & CStr(i))).Value = CheckBox61.Valu

its saying Sub or function not define

is it because before adding this set of Checkbox, I have added other Active X controls and hence the index value is not matching?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Checkbox behaving strangely

These are checkboxes from the control toolbox used on a worksheet?

Option Explicit
Private Sub CheckBox61_Click()
Dim i As Long ' index
For i = 41 To 60
Me.OLEObjects("checkbox" & i).Object.Value = CheckBox61.Value
Next i
End Sub



Shilps wrote:

Its giving Syntax Error.
When I changed the code to
dim i as long ' index

for i= 41 to 60
("checkbox" & Cstr(i)).Value = checkbox61.Value
Next
It is giving Compile Error:
Expected: Line number or label or statement or end of statement

When I change the code to

Controls(("Checkbox" & CStr(i))).Value = CheckBox61.Value

its saying Sub or function not defined

is it because before adding this set of Checkbox, I have added other Active X controls and hence the index value is not matching?


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Checkbox behaving strangely

I'm Dave but now nothing is happening. Now when I click on Checkbox61, not even a single Checkbox from index 41 to 60 is getting selected. Yes these are the Checkboxes added to the worksheet from the control toolbox


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Checkbox behaving strangely

Do you have the code behind the correct sheet?

click on the design mode button on that control toolbox toolbar.

Doubleclick on checkbox61. You'll see where the code belongs.

(Don't forget to exit design mode when you're done.)

It did work for me (although, I changed the number of checkboxes (too lazy to
make 61!)).

If it doesn't work, try creating new worksheet in a new workbook. Add a few
checkboxes from the controltoolbox and add the code to the first checkbox. (and
change that loop to " for i = 2 to 5" (or how many you added)).

Shilps wrote:

I'm Dave but now nothing is happening. Now when I click on Checkbox61, not even a single Checkbox from index 41 to 60 is getting selected. Yes these are the Checkboxes added to the worksheet from the control toolbox


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Checkbox behaving strangely

Thanks Dave .Actually that is what I want to ask. In my sheet, everything is correct, logically and syntax-wise. Then why is it not working? Could it be some problem in Excel. It s not easy for me to create a new sheet as beside this there is lot of other calculations in this sheet. I created a copy of it, but it didn't help
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Checkbox behaving strangely

Could it be a problem in xl? Yeah, but I know from my experience, it's usually
my problem--not excel's. I wouldn't give up looking for it.

You have do have macros enabled, right?

Maybe you could create a skinnied down test workbook with just a few checkboxes
to see if you can get that working. Once you do, it might be easier to find the
problem in the original.

Did you go into design mode and double click on the checkbox? And did you see
your code?



Shilps wrote:

Thanks Dave .Actually that is what I want to ask. In my sheet, everything is correct, logically and syntax-wise. Then why is it not working? Could it be some problem in Excel. It s not easy for me to create a new sheet as beside this there is lot of other calculations in this sheet. I created a copy of it, but it didn't help


--

Dave Peterson

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checkbox behaving strangely


Thanks Dave for the motivation. With a new zest, I looked into the cod
and found the error. I had named the ComboBox41 as ComboBox1.


Dave Peterson wrote:
*Could it be a problem in xl? Yeah, but I know from my experience
it's usually
my problem--not excel's. I wouldn't give up looking for it.

You have do have macros enabled, right?

Maybe you could create a skinnied down test workbook with just a fe
checkboxes
to see if you can get that working. Once you do, it might be easie
to find the
problem in the original.

Did you go into design mode and double click on the checkbox? An
did you see
your code?



Shilps wrote:[vbcol=seagreen]

Thanks Dave .Actually that is what I want to ask. In my sheet

everything is correct, logically and syntax-wise. Then why is it no
working? Could it be some problem in Excel. It s not easy for me t
create a new sheet as beside this there is lot of oth[/vbcol]
er calculations in this sheet. I created a copy of it, but it didn'
help

--

Dave Peterson



-
shilp
-----------------------------------------------------------------------
Posted via
http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message573839.htm

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
"paste picture link" behaving strangely Michael R Excel Discussion (Misc queries) 0 July 7th 09 05:06 PM
my arrow keys are behaving strangely Missing Pieces New Users to Excel 1 November 10th 08 09:22 PM
Conditional formatting acting strangely Potoroo Excel Discussion (Misc queries) 1 August 3rd 06 06:36 AM
Excel is behaving strangely for no apparent reason. canyondude New Users to Excel 4 January 10th 06 01:07 AM
Validation list behaving strangely in 2003 Danny J Excel Worksheet Functions 2 December 8th 04 09:00 AM


All times are GMT +1. The time now is 02:50 AM.

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"