+ Reply to Thread
Results 1 to 8 of 8

Limit the number of values' occurrences

  1. #1
    Registered User
    Join Date
    12-02-2022
    Location
    Denmark
    MS-Off Ver
    16.66.1
    Posts
    4

    Smile Limit the number of values' occurrences

    Hi,
    I have a A column which has 9 rows with a dropdown options including 2, 3, 4. How can I limit the number of occurences of value 2, 3, 4 with twice, 3 times, 4 times respectively?
    For example, if I filled value "2" twice, value "3" twice, value "4" twice, I can no longer fill another empty cell with value 2, meaning the dropdown list only appear the remaining options which are 3, 4.
    Screenshot 2022-12-02 at 4.28.27 PM.png

  2. #2
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    MA, USA
    MS-Off Ver
    365(PC) V:2412
    Posts
    1,477

    Re: Limit the number of values' occurrences

    the only way i could think of coming close to this is to utilize a helper column in column B. This will count the amount of time above the # has occured. It will return ERROR in the cell next to column A where the count has gotten to high. Mind you they can still input a 2,3, or 4 in column A but will keep saying ERROR in column B.
    See my attached workbook.
    Dropdown lists are in A1:A20
    Helper formula is in B1:B20.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    <----- If you are happy with your solution please click on the "* Add Reputation" as a way to say thank you.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Limit the number of values' occurrences

    Next time, please attach an Excel file, rather than a non-editable picture of one.

    Does this do what you want? If so, I'll epxlain.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  4. #4
    Registered User
    Join Date
    12-02-2022
    Location
    Denmark
    MS-Off Ver
    16.66.1
    Posts
    4

    Re: Limit the number of values' occurrences

    I did consider this option but rather look for another solution which makes the file less complex. Anyway, thank you so much!

  5. #5
    Registered User
    Join Date
    12-02-2022
    Location
    Denmark
    MS-Off Ver
    16.66.1
    Posts
    4

    Re: Limit the number of values' occurrences

    Quote Originally Posted by Glenn Kennedy View Post
    Next time, please attach an Excel file, rather than a non-editable picture of one.

    Does this do what you want? If so, I'll epxlain.
    Yes, thank you! That's exactly what I am looking for. Please help explain this.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Limit the number of values' occurrences

    Sheet Choices.

    Column A enter the values you want to allow in the dropdown (DD) list.

    Column B enter the numbe rof each one permitted.

    Column C counts the number already used in the YELLOW cells in ENTRY (NB formula has been changed):
    =COUNTIF(Entry!$A$3:$A$11,A2)

    copied down.

    Column D (copied down)
    =IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$4)/($B$2:$B$4>$C$2:$C$4),ROWS($1:1))),"")

    Red - return the values in column A
    Orange - from these rows
    Cyan - started from the one with the smallest row number
    Blue - that meets the criterion - number allowed is greater than the number used
    Purple - one at a time, starting from the first one in col A, then the second, etc.


    To avoid having blanks in the drop down box, I sed a Named range (called namelist) to select ONLY the non-blank values in column D CTRL-F3 to view/edit

    =Choices!$D$2:INDEX(Choices!$D$2:$D$4,SUMPRODUCT(--(LEN(Choices!$D$2:$D$4)>0)))

    Basically, it starts from D2 (red) and looks down to D4 (orange) and returns the values in D2:D4 which have a length >0.

    Finally, in sheet ENTRY, set up data validation in the yellow cells: Data/DataVailidation/List/=Namelist.

    Use the file attached here, as opposed to the earlier one.

    If you need more choices, etc, modify the bits in red (below) to suit.

    =COUNTIF(Entry!$A$3:$A$11,A2)

    =IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$4)/($B$2:$B$4>$C$2:$C$4),ROWS($1:1))),"")


    Choices!$D$2:INDEX(Choices!$D$2:$D$4,SUMPRODUCT(--(LEN(Choices!$D$2:$D$4)>0)))

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please click on "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 12-03-2022 at 08:56 AM.

  7. #7
    Registered User
    Join Date
    12-02-2022
    Location
    Denmark
    MS-Off Ver
    16.66.1
    Posts
    4

    Re: Limit the number of values' occurrences

    Thank you so much! It works perfectly.
    Last edited by Glenn Kennedy; 12-07-2022 at 12:44 PM.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Limit the number of values' occurrences

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please click on "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

+ 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. [SOLVED] Extract distinct text values with number of occurrences of each
    By Prabhakar1 in forum Excel General
    Replies: 7
    Last Post: 02-03-2021, 11:52 AM
  2. Getting number of occurrences of values in specific columns
    By jomelprototype in forum Excel General
    Replies: 1
    Last Post: 01-23-2020, 09:15 AM
  3. Deleting consecutive values only if they exceed a certain number of occurrences
    By Charles_S in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-30-2018, 11:46 AM
  4. Replies: 1
    Last Post: 08-08-2018, 12:18 PM
  5. Replies: 8
    Last Post: 08-16-2016, 10:27 PM
  6. Trying to count the number of occurrences of duplicate values
    By rahworks in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-11-2014, 02:55 PM
  7. [SOLVED] Count number of occurrences for a number of ranges from a find loop
    By ANDREWA in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-23-2012, 07:53 PM

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