+ Reply to Thread
Results 1 to 7 of 7

Filling in a cell based on Checkbox true/false

  1. #1
    Registered User
    Join Date
    11-10-2007
    Posts
    5

    Filling in a cell based on Checkbox true/false

    I'm rather new to Excel and VB, so please bear with me.

    In a nutshell I'd like to do the following:

    I've got a checkbox in my worksheet. I'd like the contents of a cell to change depending on whether or not that checkbox is ticked or not.

    I realize this isn't the proper code, but in "plain english" it would be something like this:

    If CheckBox5 = True then K43 = R38-(R38*0.15)

    If CheckBox5 = False then K43 = 0

    Again, I realize that's not the correct code, but that's what I'd like it to do.

    Any help? Thanks.

  2. #2
    Forum Guru mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,207
    Link the checkbox to a cell, like A1

    Then if you put =A1*(R38-(R38*0.15))in K43 should do what you want.

  3. #3
    Registered User
    Join Date
    11-10-2007
    Posts
    5
    After doing some more searching on this forum, I've found some code to ensure that only one of the checkboxes can be selected at a time (which is what I'd like to do) However, I'm still not sure how to change the contents of a cell after doing the check to see that both checkboxes aren't selected. Here's what I have thus far..

    Please Login or Register  to view this content.
    Last edited by Rivalwon; 11-10-2007 at 04:43 PM.

  4. #4
    Forum Guru mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,207
    Option Buttons act like checkboxes but only one can be checked at a time.

  5. #5
    Registered User
    Join Date
    11-10-2007
    Posts
    5
    After some more digging, I've got the following:

    Please Login or Register  to view this content.
    That worked and set the value of K43 to zero if the Agency Net checkbox is checked. However, I'm still running into problems with the other checkbox. I thought the following would work.

    Please Login or Register  to view this content.
    That doesn't appear to work. Any help on where I've gone wrong here? Thanks..

  6. #6
    Forum Guru mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,207
    If you want to put a formula in a cell, use the .Formula property of the Range, as in
    Please Login or Register  to view this content.
    To calculate the value and put that in the cell, I'd try
    Please Login or Register  to view this content.

    Is there a reason to insist on VB, linking controls to cells and using worksheet functions would be much faster.
    Last edited by mikerickson; 11-10-2007 at 05:45 PM.

  7. #7
    Registered User
    Join Date
    11-10-2007
    Posts
    5
    That worked. Thank-you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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