+ Reply to Thread
Results 1 to 7 of 7

Formula to count array of 1s?

  1. #1
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Wink Formula to count array of 1s?

    hi excelers,
    Can anyone help me with this problem which I can't find a solution:
    I need a Formula to count array SEQUENCE of connecting 1s, which works on any angle and number of cells (see attached examples).

    If it is possible, I would be grateful for any suggestions to a solution... thx

    PS I hope to calculate this in one excel function?
    Attached Files Attached Files
    Last edited by QuantEdge; 04-27-2019 at 06:30 AM.

  2. #2
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Formula to count array of 1s?

    Hi

    is TEXTJOIN function recognised by your Excel?

    Example in AU2 confirmed with control+shift+enter

    =MAX(IF(ISNUMBER(FIND("-"&REPT(1,ROW(1:10))&"-","-"&TEXTJOIN("",0,SUBSTITUTE(AU4:BC8,"0","-"))&"-")),ROW(1:10)))

    In AM2

    =MAX(IF(ISNUMBER(FIND("-"&REPT(1,ROW(1:10))&"-","-"&TEXTJOIN("",0,SUBSTITUTE(AM8:AT8,"0","-"))&"-")),ROW(1:10)))

    In E2

    =MAX(IF(ISNUMBER(FIND("-"&REPT(1,ROW(1:10))&"-","-"&TEXTJOIN("",0,SUBSTITUTE(E4:E8,"0","-"))&"-")),ROW(1:10)))


    and so on


    I'm using an UDF, because TEXTJOIN is not available on my Excel 2010


    Please Login or Register  to view this content.

    Regards
    Attached Files Attached Files
    Last edited by canapone; 04-27-2019 at 07:23 AM.
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Formula to count array of 1s?

    thx canapone, but how do I add the UDF?

  4. #4
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Formula to count array of 1s?

    Ciao

    From Google:

    Follow along to create custom functions:
    Press Alt + F11. ...
    Choose Insert→Module in the editor. ...
    Type this programming code, shown in the following figure: ...
    Save the function. ...
    Return to Excel.
    Click the Insert Function button on the Formulas tab to display the Insert Function dialog box. ...
    Click OK.

    As I'm using TEXTJOIN very often, I've preferred to open a new file, add the function (please see again instructions) and save the new file as .XLAM in order to see the new function among the additional excel components.
    Last edited by canapone; 04-27-2019 at 08:09 AM.

  5. #5
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Formula to count array of 1s?

    Hi again

    I forgot to tell you that the formulas intercept at most 10 consecutive 1s.

    If you'd need to measure longer series, please adjust the two "ROW(1:10)" in the formula.

    Quite sure the formulas could produce unexpected results: maybe VBA can offer more robust approach.

    Regards
    Last edited by canapone; 04-27-2019 at 08:26 AM.

  6. #6
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Formula to count array of 1s?

    thx canapone, just think there should be a similar solution?

  7. #7
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Formula to count array of 1s?

    Hi,


    I'm afraid I'm not of a great help with the VBA

    Hope you'll get other solutions...

+ 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] Count with Array formula
    By TPDave in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-11-2015, 10:00 AM
  2. [SOLVED] Count If Array Formula
    By carl in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-21-2005, 04:55 PM
  3. How can you use count with an array formula similar to using sum
    By Ragdyer in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-06-2005, 12:05 PM
  4. How can you use count with an array formula similar to using sum
    By Ragdyer in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-06-2005, 07:05 AM
  5. [SOLVED] How can you use count with an array formula similar to using sum
    By PhilH in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  6. How can you use count with an array formula similar to using sum
    By PhilH in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  7. [SOLVED] How can you use count with an array formula similar to using sum
    By PhilH in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-27-2005, 03:05 AM

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