+ Reply to Thread
Results 1 to 4 of 4

Using ActiveX CheckBox Control to make a cell change colour and clear values

  1. #1
    Registered User
    Join Date
    08-19-2012
    Location
    NZ
    MS-Off Ver
    Excel 2010
    Posts
    5

    Using ActiveX CheckBox Control to make a cell change colour and clear values

    Hi everyone

    I'm a total noob at VBA so please be nice

    I'm developing a spreadsheet that has a series of ActiveX CheckBox controls.

    With one in particular, I'm trying to get the checkbox to control what is displayed in a particular cell. What I want is this:

    CheckBox checked: Change cell colour to red/pink, but only until a number is entered in it
    CheckBox unchecked: Change cell colour back to 'no fill', and clear any values already typed in.

    Here is the code I'm using:

    Please Login or Register  to view this content.
    Please forgive the terrible flow of it all, as I said this is my first crack at this and the code has been cobbled together by reading a bunch of various posts, none of which I fully understand - my knowledge of syntax is next to nil at the moment, but I'm working on it!

    Cheers
    Last edited by Cutter; 08-19-2012 at 08:58 PM. Reason: Added code tags

  2. #2
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Using ActiveX CheckBox Control to make a cell change colour and clear values

    @ drmit

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Using ActiveX CheckBox Control to make a cell change colour and clear values

    You can't do that with justa chckbox. Once run the code will not recognise when a number is entered. Why not use a WorkSheet event instead of the checkboxes.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    08-19-2012
    Location
    NZ
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Using ActiveX CheckBox Control to make a cell change colour and clear values

    Thanks for the tip Roy.

    I considered trying to code it that way but I couldn't figure out how to only colour the cell when the checkbox is ticked from a WorkSheet event. It would be pretty straightforward to colour the cell depending on whether any text was entered using conditional formatting outside of VBA, but I guess it brings me back to my original question - how do I get the cell to change colours only when the checkbox is ticked?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1