+ Reply to Thread
Results 1 to 13 of 13

Using the Power of two to find which options are selected in a recursive fashion

  1. #1
    Registered User
    Join Date
    11-01-2021
    Location
    Oslo
    MS-Off Ver
    Office365
    Posts
    6

    Using the Power of two to find which options are selected in a recursive fashion

    I have a list of options which each has a unique value in the form of Power of Two, 0-24 all corresponding to an option:
    Power of two options.png
    I also have a list with a number, ("Moduler"), corresponding to one or more of these options.
    List of options.png
    I would like to for each such number break out which options has been set.
    I am thinking on the lines of a recursive calclulation in each column, but I am not sure as how to do it properly. Lowest and highest value is fine, but it is the options in between which are difficult.

    Any Ideas here?

    See attached file "Lisenser_perland_20210128.xlsx" for none sensetive information.
    Attached Files Attached Files
    Last edited by J_Andreas_Lindqvist; 11-01-2021 at 09:13 AM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,264

    Re: Using the Power of two to find which options are selected in a recursive fashion

    I would not use powers of two, but rely on decades.

    So your first set of options are 1-9, the second are 10, 20, 30 --- 90, the third are 100, 200, 300, ---- 900 When you add them, you get a number that uniquely specifies the selections, like

    732 7th from the third set, 3rd from the second set, and 2nd from the first set.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    11-01-2021
    Location
    Oslo
    MS-Off Ver
    Office365
    Posts
    6

    Re: Using the Power of two to find which options are selected in a recursive fashion

    Hello and thank you for the reply!

    the power of two is nothing I can change, that is how the options are structured in the source and that is what I need help to manage.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,711

    Re: Using the Power of two to find which options are selected in a recursive fashion

    See sheet1: is this what you require where "1" indicates a selection ? (Illustration only!)

    "Moduler" value in A1

    Please Login or Register  to view this content.
    NOTE: heading in the 2 sheets are not consistent in order or content

    UPDATED with BD change
    Attached Files Attached Files
    Last edited by JohnTopley; 11-02-2021 at 02:27 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,264

    Re: Using the Power of two to find which options are selected in a recursive fashion

    Nice code - but you might want <= instead of just less than, to capture the last value.

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,711

    Re: Using the Power of two to find which options are selected in a recursive fashion

    @Bernie: thank you.

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,264

    Re: Using the Power of two to find which options are selected in a recursive fashion

    Here's a formula solution, based on John Topley's logic:

    In A4, enter

    =IF(A2<=$A$6-SUM(B4:$Z4),A2,0)

    And copy to B4:Y4. Enter the sum of the values into A6, and the numbers that sum to that value will be shown in row 4.

  8. #8
    Valued Forum Contributor
    Join Date
    07-13-2021
    Location
    California, USA
    MS-Off Ver
    2010
    Posts
    513

    Re: Using the Power of two to find which options are selected in a recursive fashion

    Quote Originally Posted by J_Andreas_Lindqvist View Post
    the power of two is nothing I can change, that is how the options are structured in the source
    Good choice, IMHO. But that is limited to 53 options.

    (Excel does not format the sum with option 2^50, 2^51 and 2^52 correctly. But they are accounted for correctly.)

    Enter the following into D2 and copy across into E2:T2:

    =IFERROR(IF(ISODD(INT([@Moduler]/2^(MATCH(D$1,'VB Moduler'!$A$1:$Y$1,0)-1))),1,""),"")

    The structured Table automagically copies the formulas down their respective columns.
    Last edited by curiouscat408; 11-03-2021 at 02:11 AM.

  9. #9
    Registered User
    Join Date
    11-01-2021
    Location
    Oslo
    MS-Off Ver
    Office365
    Posts
    6

    Re: Using the Power of two to find which options are selected in a recursive fashion

    To curiouscat408, as "You are not allowed to post any kinds of links, images or videos until you post a few times."

    Thank you very much! That worked perfectly.
    The system the options are from are based much on Excel, and this limitation is never exceded and will therefore not cause any issue for this purpose.

  10. #10
    Registered User
    Join Date
    11-01-2021
    Location
    Oslo
    MS-Off Ver
    Office365
    Posts
    6

    Re: Using the Power of two to find which options are selected in a recursive fashion

    To Bernie
    Thank you very much!

  11. #11
    Registered User
    Join Date
    11-01-2021
    Location
    Oslo
    MS-Off Ver
    Office365
    Posts
    6

    Re: Using the Power of two to find which options are selected in a recursive fashion

    To JohnTopley
    Thank you very much! Lots of good sugestions here but the solution of Curiouscat408 fit me perfectly. :-)

  12. #12
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,371

    Re: Using the Power of two to find which options are selected in a recursive fashion

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.
    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.

  13. #13
    Registered User
    Join Date
    11-01-2021
    Location
    Oslo
    MS-Off Ver
    Office365
    Posts
    6

    Re: Using the Power of two to find which options are selected in a recursive fashion

    Done!
    Thank you very much!

+ 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] Formulas required for different options selected
    By sameer79 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-27-2020, 04:50 AM
  2. Power Query - Load to dialog box seems to be missing options
    By carlito2002wgn in forum Excel General
    Replies: 1
    Last Post: 09-30-2020, 03:22 AM
  3. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM
  4. [SOLVED] Can't find corrext Index Match formula where different options have same sub-options
    By Ochimus in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-27-2016, 06:59 AM
  5. [SOLVED] Recursive find of managers
    By flyboy54 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-22-2013, 11:32 AM
  6. Find & replace recursive
    By mmer2 in forum Excel General
    Replies: 7
    Last Post: 07-18-2012, 08:41 AM
  7. Find most recent file in recursive filtered folder
    By camaytoc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-06-2011, 05:58 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