+ Reply to Thread
Results 1 to 12 of 12

Checkbox COUNTIF

Hybrid View

JN831 Checkbox COUNTIF 12-02-2023, 12:29 PM
AliGW Re: Checkbox COUNTIF 12-02-2023, 12:39 PM
JN831 Re: Checkbox COUNTIF 12-02-2023, 01:02 PM
AliGW Re: Checkbox COUNTIF 12-02-2023, 01:03 PM
JN831 Re: Checkbox COUNTIF 12-02-2023, 01:07 PM
AliGW Re: Checkbox COUNTIF 12-02-2023, 01:15 PM
JN831 Re: Checkbox COUNTIF 12-02-2023, 03:07 PM
AliGW Re: Checkbox COUNTIF 12-02-2023, 06:13 PM
JN831 Re: Checkbox COUNTIF 12-03-2023, 01:35 PM
HansDouwe Re: Checkbox COUNTIF 12-03-2023, 02:34 PM
JN831 Re: Checkbox COUNTIF 12-03-2023, 03:56 PM
HansDouwe Re: Checkbox COUNTIF 12-03-2023, 04:20 PM
  1. #1
    Forum Contributor
    Join Date
    04-04-2023
    Location
    Detroit, Michigan
    MS-Off Ver
    365 Version 2409
    Posts
    285

    Checkbox COUNTIF

    So I recently upgraded to Office 365 beta version to utilize the new Checkboxes in Excel. It's really cool but I have a question about the formula I wrote.

    I count the checkboxes with the COUNTIF function and the value that gets assigned to each checkbox that's ticked is either 3 or 7.

    But because of the way I have each factor for the checkboxes organized, the 3 and 7 values are not all grouped together. The only way I could see to account for this was to use multiple COUNTIF functions in the formula. Thus, the formula is quite long.

    I just wanted to know, is there a simple way to shorten my formula?

    Formula: copy to clipboard
    =IF(B1="","",COUNTIF(B3:B6,TRUE)*3+COUNTIF(B7,TRUE)*7+COUNTIF(B8:B16,TRUE)*3+COUNTIF(B17,TRUE)*7+COUNTIF(B18,TRUE)*3+COUNTIF(B19,TRUE)*7+COUNTIF(B20,TRUE)*3+COUNTIF(B21,TRUE)*7+COUNTIF(B22:B25,TRUE)*3)
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,231

    Re: Checkbox COUNTIF

    What's the rule for when a factor should be 3 or 7? If there isn't one, then add a helper column:

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    A
    B
    C
    3
    Factor 1
    3
    4
    Factor 2
    3
    5
    Factor 3
    3
    6
    Factor 4
    3
    7
    Factor 5
    7
    8
    Factor 6
    3
    9
    Factor 7
    3
    10
    Factor 8
    3
    11
    Factor 9
    3
    12
    Factor 10
    3
    13
    Factor 11
    3
    14
    Factor 12
    3
    15
    Factor 13
    3
    16
    Factor 14
    3
    17
    Factor 15
    7
    18
    Factor 16
    3
    19
    Factor 17
    7
    20
    Factor 18
    3
    21
    Factor 19
    7
    22
    Factor 20
    3
    23
    Factor 21
    3
    24
    Factor 22
    3
    25
    Factor 23
    3
    Sheet: Sheet1

    =IF(B1="","",SUMPRODUCT((B3:B25=TRUE)*C3:C25))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    04-04-2023
    Location
    Detroit, Michigan
    MS-Off Ver
    365 Version 2409
    Posts
    285

    Re: Checkbox COUNTIF

    Thank you for the helper column suggestion.

    The rules for when a factor should be 3 or 7 are based upon the weighting of each factor. Some factors are more important and thus get the higher weighting.

    In my example I only show one column but there are 20 different adjacent columns in my spreadsheet with these checkboxes. So 20 helper columns wouldn't be practical.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,231

    Re: Checkbox COUNTIF

    Without a rule, there's no simpler way of doing it. Sorry!

  5. #5
    Forum Contributor
    Join Date
    04-04-2023
    Location
    Detroit, Michigan
    MS-Off Ver
    365 Version 2409
    Posts
    285

    Re: Checkbox COUNTIF

    I don't understand how the rule for the weighting each factor is relevant. Please tell me how assigning a weighting to each factor affects how each checkbox is counted.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,231

    Re: Checkbox COUNTIF

    Your current formula is this:

    =IF(B1="","",COUNTIF(B3:B6,TRUE)*3+COUNTIF(B7,TRUE)*7+COUNTIF(B8:B16,TRUE)*3+COUNTIF(B17,TRUE)*7+COUNTIF(B18,TRUE)*3+COUNTIF(B19,TRUE)*7+COUNTIF(B20,TRUE)*3+COUNTIF(B21,TRUE)*7+COUNTIF(B22:B25,TRUE)*3)

    You have said that there is no rule as to which rows will be weighted 3 and which 7, so I understand it to be (a) random and (b) likely to change.

    Without a rule you can't shorten the formula. I suggested a helper column, but this now appears not to be feasible.

  7. #7
    Forum Contributor
    Join Date
    04-04-2023
    Location
    Detroit, Michigan
    MS-Off Ver
    365 Version 2409
    Posts
    285

    Re: Checkbox COUNTIF

    The weighting is not random and the weighting of the factors does not change.

    weighting are based upon factors that I assumed were irrelevant to the count. But perhaps I'm wrong. See below for and example of one of the rules.

    The weighting for Factor 4 (row 6) is based upon the percentage of times a contestant finished 2nd or 3rd. If its from 10% - 19%, the checkbox gets ticked and they receive 3 points.

    The weighting for Factor 5 (row 7) is also based upon the percentage of times a contestant finished 2nd or 3rd. However, for the checkbox to get ticked for Factor 5, the percentage must be greater than or equal to 20% and the contestant receives 7 points.

    Note: only one checkbox gets ticked according to the rule above. In other words, if the percentage is 20% or higher only Factor 5 gets a tick in the checkbox. If the percentage is less then 10% then neither checkbox gets ticked.


    Not sure if this helps but that's an example of the rules and I don't see how it's relevant to the formula using COUNTIF. Either way, you have said its not possible to shorten the formula without a helper column.
    Last edited by JN831; 12-02-2023 at 03:14 PM.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,231

    Re: Checkbox COUNTIF

    Unless I’m missing something, all there is in the workbook is a list of factors, a checkbox list and your formula. I don’t see anything else. Maybe you need to put this in a broader context, but as it stands, I don’t see how it’s possible to shorten your formula without a helper column.

  9. #9
    Forum Contributor
    Join Date
    04-04-2023
    Location
    Detroit, Michigan
    MS-Off Ver
    365 Version 2409
    Posts
    285

    Re: Checkbox COUNTIF

    Okay, you're much more Excel savvy than I am, and I thank you for your help and knowledge.

    My formula works, I just thought (perhaps with another function) that it might be able to be shortened. But I guess that old saying applies here: "If it aint broke, don't fix it"

    Thanks again, Ali

  10. #10
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Checkbox COUNTIF

    This formula is equivalent to your formula, but shorter:

    Please try:
    Formula: copy to clipboard
    =IF(B1="","",SUM(--B3:B25))*3+(B7+B17+B19+B21)*4
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    04-04-2023
    Location
    Detroit, Michigan
    MS-Off Ver
    365 Version 2409
    Posts
    285

    Re: Checkbox COUNTIF

    @HansDouwe, that works perfectly!

    Much shorter and cleaner than my formula and no helper column needed.

    That's exactly what I was looking for. Simple and no need for rules of the factors involved, which I thought were likely irrelevant anyway.

    Thank you so much!

  12. #12
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Checkbox COUNTIF

    You are Welcome!

    Thanks for the feedback and rep .


    Glad to have helped.

+ 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. How To: When Checkbox = True, Cell X1 = Date Checkbox was checked
    By jjward101 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-08-2022, 02:32 PM
  2. [SOLVED] Highlght checkbox yellow using countif and conditional formatting
    By L plates in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2015, 09:49 AM
  3. Select All Checkboxes Checkbox That Also Calls Checkbox Macros
    By Intervigilium in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2015, 06:41 PM
  4. Protect the sheet but the form checkbox still can be change and sort by checkbox
    By carolyn1221 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-19-2014, 01:08 PM
  5. Lock cell linked to checkbox when checkbox is ticked
    By simeony003 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2013, 10:08 AM
  6. Replies: 4
    Last Post: 07-22-2013, 01:37 PM
  7. [SOLVED] How do I change a checkbox to unchecked without running the code within the checkbox
    By jsunnb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2012, 09:28 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