Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / June 2007

Tip: Looking for answers? Try searching our database.

CheckBox code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Khalil Handal - 19 Jun 2007 13:13 GMT
Hello to everybody,
I have a sheet for showing a certificate of marks. Sometimes Ithe sum of the
marks need to be shown when printing the certificate, and sometime I n don't
need to see the sum.
I have a checkBox named chekcbox1 on the sheet. What I need is a VBA code so
that when the box is checked to hide the contents of the range C34:E34 which
containes the sum of the marks.
PS. by "hiding" I mean "not to be seen. (maybe changing their color to
white!!)
Can anyone help in writing the code for me?
FSt1 - 19 Jun 2007 13:53 GMT
hi
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
   Range("C34:E34").Font.Color = RGB(255, 255, 255) ' white
   Else
   Range("C34:E34").Font.Color = RGB(0, 0, 0) 'black
End If
End Sub

regards
FSt1

> Hello to everybody,
> I have a sheet for showing a certificate of marks. Sometimes Ithe sum of the
[quoted text clipped - 6 lines]
> white!!)
> Can anyone help in writing the code for me?
Khalil Handal - 19 Jun 2007 14:44 GMT
Thanks.It worked well

> hi
> Private Sub CheckBox1_Click()
[quoted text clipped - 22 lines]
>> white!!)
>> Can anyone help in writing the code for me?
Khalil Handal - 19 Jun 2007 14:52 GMT
Hi,
My sheet is protected and the cells are protected.
It does not work in this case what should I do????

> hi
> Private Sub CheckBox1_Click()
[quoted text clipped - 22 lines]
>> white!!)
>> Can anyone help in writing the code for me?
Gord Dibben - 19 Jun 2007 16:05 GMT
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
ActiveSheet.UnProtect
   Range("C34:E34").Font.Color = RGB(255, 255, 255) ' white
   Else
   Range("C34:E34").Font.Color = RGB(0, 0, 0) 'black
End If
ActiveSheet.Protect
End Sub

Gord Dibben  MS Excel MVP

>Hi,
>My sheet is protected and the cells are protected.
[quoted text clipped - 26 lines]
>>> white!!)
>>> Can anyone help in writing the code for me?
Khalil Handal - 19 Jun 2007 16:51 GMT
Hi,
When I clicked the box the first time it worked fine.
Then I clicked it again (a second time) and had the following error message:
Unable to set the color property of the font class
any ideas!!!!

> Private Sub CheckBox1_Click()
> If CheckBox1.Value = True Then
[quoted text clipped - 40 lines]
>>>> white!!)
>>>> Can anyone help in writing the code for me?
Dave Peterson - 19 Jun 2007 18:29 GMT
Moving the .unprotect line helped:

Option Explicit
Private Sub CheckBox1_Click()
   Me.Unprotect
   If CheckBox1.Value = True Then
       Me.Range("C34:E34").Font.Color = RGB(255, 255, 255) ' white
   Else
       Me.Range("C34:E34").Font.Color = RGB(0, 0, 0) 'black
   End If
   Me.Protect
End Sub

The me keyword refers to the worksheet that owns the code.

> Hi,
> When I clicked the box the first time it worked fine.
[quoted text clipped - 46 lines]
> >>>> white!!)
> >>>> Can anyone help in writing the code for me?

Signature

Dave Peterson

Khalil Handal - 19 Jun 2007 18:55 GMT
Thanks a lot to all of you.
It worked just fine

> Moving the .unprotect line helped:
>
[quoted text clipped - 70 lines]
>> >>>> white!!)
>> >>>> Can anyone help in writing the code for me?
Rick Rothstein (MVP - VB) - 19 Jun 2007 17:30 GMT
Even more descriptive (in my opinion) are these (which use two of the many,
many predefined constants in VBA)...

>    Range("C34:E34").Font.Color = RGB(255, 255, 255) ' white

Range("C34:E34").Font.Color = vbWhite

>    Range("C34:E34").Font.Color = RGB(0, 0, 0) 'black

Range("C34:E34").Font.Color = vbBlack

Rick
Khalil Handal - 19 Jun 2007 19:00 GMT
Yours also worked well; it gave the same result.
thanks

> Even more descriptive (in my opinion) are these (which use two of the
> many, many predefined constants in VBA)...
[quoted text clipped - 8 lines]
>
> Rick

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.