Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Disable Checkbox on Userform

I have a Userform with 6 Checkboxes on it. What I want it to do is if there
are 4 worksheets in the workbook then 4 of the checkboxes would be enabled
and 2 of the checkboxes would be disabled, if there are 3 worksheets in the
workbook then 4 of the checkboxes would be enabled and 3 of the checkboxes
would be disabled, and so on, is this possible?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Disable Checkbox on Userform

something like this would work

Private Sub UserForm_Initialize()
wscount=activeworkbook.worksheets.count
If wscount<6 then
CheckBox6.Enabled = False
End If
If wscount<5 then
CheckBox5.Enabled = False
End If

'ADD THE REST HERE

End Sub

--
Paul Cordts


"jnf40" wrote:

I have a Userform with 6 Checkboxes on it. What I want it to do is if there
are 4 worksheets in the workbook then 4 of the checkboxes would be enabled
and 2 of the checkboxes would be disabled, if there are 3 worksheets in the
workbook then 4 of the checkboxes would be enabled and 3 of the checkboxes
would be disabled, and so on, is this possible?
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Disable Checkbox on Userform

Instead of handling each Checkbox separately, you can do it in a loop
instead...

Private Sub UserForm_Initialize()
Dim X As Long
Dim WScount As Long
WScount = ActiveWorkbook.Worksheets.Count
For X = 1 To 6
Me.Controls("CheckBox" & CStr(X)).Enabled = (X <= WScount)
Next
End Sub

Rick


"Paul Cordts" wrote in message
...
something like this would work

Private Sub UserForm_Initialize()
wscount=activeworkbook.worksheets.count
If wscount<6 then
CheckBox6.Enabled = False
End If
If wscount<5 then
CheckBox5.Enabled = False
End If

'ADD THE REST HERE

End Sub

--
Paul Cordts


"jnf40" wrote:

I have a Userform with 6 Checkboxes on it. What I want it to do is if
there
are 4 worksheets in the workbook then 4 of the checkboxes would be
enabled
and 2 of the checkboxes would be disabled, if there are 3 worksheets in
the
workbook then 4 of the checkboxes would be enabled and 3 of the
checkboxes
would be disabled, and so on, is this possible?
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
link a checkbox in a sheet to a checkbox on a userform? Arjan Excel Programming 0 November 10th 06 01:37 PM
Disable a checkbox dependant upon cell data frendabrenda1 Excel Discussion (Misc queries) 1 September 2nd 05 02:03 PM
CheckBox in userform MD Excel Programming 2 December 2nd 04 06:42 PM
CheckBox on UserForm Michel[_4_] Excel Programming 0 August 3rd 04 12:38 AM
Userform and checkbox.... Ben.c Excel Programming 3 December 19th 03 05:56 PM


All times are GMT +1. The time now is 07:41 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"