+ Reply to Thread
Results 1 to 7 of 7

Deactivate cells based on checkbox selection and exclude inactive cells from SUM

  1. #1
    Forum Contributor
    Join Date
    10-15-2009
    Location
    Broooklyn, NY
    MS-Off Ver
    Excel 2016
    Posts
    207

    Deactivate cells based on checkbox selection and exclude inactive cells from SUM

    I was wondering if you could help me with the following:
    If I select attribute B, I want cells B10, C10, B13 and C13 deactivated. Once deactivated it, the sum should be updated to calculate only active cells. So, if I select attribute B, the total sum should be updated to 6,500.
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Deactivate cells based on checkbox selection and exclude inactive cells from SUM

    What do you mean by "deactivated" and "active" in this case?

    This update does exactly what you describe but of course you didn't mention what do to if A or C is checked.

    The easiest way to do this is with formulas. I linked each of your checkboxes to a cell, named those cells, and then the SUM formulas checks those cells to determine which values to include.

    If you select attribute B, and then B10, C10, B13, and C13 are deactivated, and you want to sum only the active cells, the correct answer is 5,000, not 6,500.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    10-15-2009
    Location
    Broooklyn, NY
    MS-Off Ver
    Excel 2016
    Posts
    207

    Re: Deactivate cells based on checkbox selection and exclude inactive cells from SUM

    No, it doesn't work. If checkbox B is selected, option 1 and option 2 have to be deactivated, as it is not applicable. So, it has to sum to 10,000 is option B is not selected. If option B is selected, it has to be deactivated (grey-out but not locked), so the sum is updated and the sum only calculates active cells. So, option 1 and option 2 are not applicable when Option B is selected, the sum has to be $6,500.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Deactivate cells based on checkbox selection and exclude inactive cells from SUM

    How are you getting 6,500?

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Deactivate cells based on checkbox selection and exclude inactive cells from SUM

    Here is a revision but your arithmetic seems to be wrong.

    This version revises it to give the total of all numbers if B is not checked. It uses conditional formatting to gray out the "deactivated" cells (these cells are in no way deactivated except conceptually).
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    10-15-2009
    Location
    Broooklyn, NY
    MS-Off Ver
    Excel 2016
    Posts
    207

    Re: Deactivate cells based on checkbox selection and exclude inactive cells from SUM

    I didn't write the right cells. If I deactivate Option 2 and Option 4, I would get $6,500. Your solution works. Can you walk me through exactly how you did it? Did you have to write any code? How did you define the name with the checkbox? Can you do it without name manager?

    Thanks.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Deactivate cells based on checkbox selection and exclude inactive cells from SUM

    Here is what I did. No VBA code was used.

    I linked each of your checkboxes to a cell

    Go to the Developer panel and click Design. Right-click the checkbox and select Properties. Type the address of the desired cell into the LinkedCell property. When the box is checked, this cell will be True and when the box is unchecked it will be False.

    named those cells

    This step is unnecessary but allows the formulas be more readable. You must use Name Manager to do this. If you prefer you can just use the cell addresses in the formula.

    and then the SUM formulas checks those cells to determine which values to include.

    For each cell, I specified the conditions that determine whether that cell is included in the sum.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Based on your last post it would be corrected to
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I also used Conditional Formatting to set the cells to be grayed out when checkbox B is selected. This is just for appearances.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 07-12-2019, 12:18 PM
  2. [SOLVED] Deactivate and Reactivate a series of cells in Excel based on a Yes/No check box
    By Kogen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-07-2018, 09:17 AM
  3. Replies: 2
    Last Post: 09-06-2018, 03:15 PM
  4. Activate/Deactivate Cell Based on ComboBox Selection
    By atalante_ in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-16-2018, 05:00 PM
  5. Replies: 1
    Last Post: 12-23-2015, 02:08 PM
  6. [SOLVED] UserFrom Checkbox Selection not populating Cells
    By midnightorion in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2015, 11:21 PM
  7. Replies: 0
    Last Post: 07-17-2007, 03:23 PM

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