PC Review


Reply
Thread Tools Rate Thread

Disable Checkbox on Userform

 
 
=?Utf-8?B?am5mNDA=?=
Guest
Posts: n/a
 
      9th Oct 2007
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 With Quote
 
 
 
 
=?Utf-8?B?UGF1bCBDb3JkdHM=?=
Guest
Posts: n/a
 
      9th Oct 2007
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 With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      9th Oct 2007
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" <(E-Mail Removed)> wrote in message
news:AD9E4CEA-6337-461E-93DE-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: UserForm CheckBox Help JLGWhiz Microsoft Excel Programming 0 21st Oct 2008 12:31 AM
link a checkbox in a sheet to a checkbox on a userform? =?Utf-8?B?QXJqYW4=?= Microsoft Excel Programming 0 10th Nov 2006 01:37 PM
Userform Checkbox Bill Microsoft Excel Programming 1 20th Jun 2006 10:07 PM
disable checkbox list checkbox Vikram Microsoft ASP .NET 1 25th Jan 2006 02:59 PM
Userform and checkbox.... =?Utf-8?B?QmVuLmM=?= Microsoft Excel Programming 3 19th Dec 2003 05:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:05 PM.