+ Reply to Thread
Results 1 to 19 of 19

Count Contiguous cells only

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Count Contiguous cells only

    Hello everyone
    I have some data in columns("B:R") ..
    The required in column A is to type Yes or No according to one criteria which is :
    If there are 6 or more adjacent cells which has data in them then type Yes in column A

    For example: in row 1 Range("I1:N1") all cells have data so the criteria is achieved so type "Yes" in A1

    In Row 2 there is no range achieved the criteria so type in A2 the word "No"

    I prefer UDF function for that task
    Thanks advanced
    Attached Files Attached Files
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count Contiguous cells only

    I tried this solution
    Please Login or Register  to view this content.
    It works well in VBA
    Please Login or Register  to view this content.
    It gives me False while when using this UDF function in worksheet it gives me True
    Please Login or Register  to view this content.

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Count Contiguous cells only

    Specialcells doesn't work in UDFs.
    Remember what the dormouse said
    Feed your head

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Count Contiguous cells only

    Quote Originally Posted by romperstomper View Post
    Specialcells doesn't work in UDFs.
    Neither does DisplayFormat. We need a list -- what else you got, Rory?
    Last edited by shg; 09-15-2015 at 06:05 PM.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Count Contiguous cells only

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count Contiguous cells only

    Thanks a lot everyone
    Mr shg I tested your udf but I got False for all ranges ...
    Thanks for help
    Please Login or Register  to view this content.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Count Contiguous cells only

    Row\Col
    A
    B
    C
    D
    E
    F
    G
    1
    6
    6
    2
    3
    TRUE
    F1: =SomeGE6(A1:D1)
    2
    3
    4
    5
    5
    FALSE
    3
    6
    1
    5
    3
    TRUE
    4
    3
    2
    2
    2
    FALSE
    5
    2
    1
    5
    6
    TRUE
    6
    2
    4
    3
    5
    FALSE

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Count Contiguous cells only

    Hello YasserKhalil,

    This worked for me. The first argument "Rng" is the range of row values to check. The second argument is the value that must occur at least six times contiguously. In your example cell "A1" would have the formula =IsCountGTE6(B1:R1, 1).

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  9. #9
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count Contiguous cells only

    @Mr. shg
    Thanks alot for help .. your UDF function would be useful for another issue ..

    @Leith Ross
    Great and awesome UDF .. Than you very much for this wonderful solution
    Just a little modification... I need to do without the second argument which specify the value that must occur
    I just need six adjacent cells that have constants (never mind the data itself)

    Thanks again for this great help

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count Contiguous cells only

    Thanks I could manage it
    Please Login or Register  to view this content.

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Count Contiguous cells only

    Hello YasserKhalil,

    You're welcome.

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Count Contiguous cells only

    Quote Originally Posted by YasserKhalil View Post
    @Mr. shg
    Thanks alot for help .. your UDF function would be useful for another issue.
    You're welcome, but I should have read the question more closely. =MAX(range)>=6 is all you'd need to replace my UDF.

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Count Contiguous cells only

    Thank you Mr. Leith
    Is it possible to do that task by formulas .. Not by VBA at all?

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Count Contiguous cells only

    Sure:

    Row\Col
    A
    B
    C
    D
    E
    1
    0
    1
    FALSE
    D1: {=MAX(FREQUENCY(IF(A1:A23=C1, ROW(A1:A23)), IF(A1:A23<>1, ROW(A1:A23)))) > 6}
    2
    1
    3
    1
    4
    1
    5
    0
    6
    1
    7
    1
    8
    1
    9
    1
    10
    0
    11
    1
    12
    1
    13
    0
    14
    1
    15
    1
    16
    1
    17
    1
    18
    0
    19
    1
    20
    1
    21
    0
    22
    1
    23
    1

  15. #15
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Count Contiguous cells only

    @shg
    Currentarray and currentregion spring to mind.

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Count Contiguous cells only

    Gracias. Also FindNext.

    Row\Col
    A
    B
    C
    D
    E
    1
    2003
    2007
    2010
    2013
    2
    Range.CurrentArray
    X
    X
    X
    ?
    3
    Range.CurrentRegion
    X
    X
    X
    ?
    4
    Range.DisplayFormat
    Didn’t exist
    Didn’t exist
    X
    ?
    5
    Range.FindNext
    X
    X
    X
    ?


    Anything else come to mind?
    Last edited by shg; 09-16-2015 at 11:48 AM.

  17. #17
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Count Contiguous cells only

    Not offhand. This is one of those topics I keep meaning to blog about - unfortunately don't have the time to research it properly just now. BTW none of them work in 2013/16 either as far as I know.

    Oh - you missed off SpecialCells...

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Count Contiguous cells only

    Thanks, Rory. My table is your table; blog away.

    Row\Col
    A
    B
    C
    D
    E
    F
    1
    Property/Method
    2003
    2007
    2010
    2013
    2016
    2
    Range.CurrentArray
    X
    X
    X
    X
    X
    3
    Range.CurrentRegion
    X
    X
    X
    X
    X
    4
    Range.DisplayFormat
    Didn’t exist
    Didn’t exist
    X
    X
    X
    5
    Range.FindNext
    X
    X
    X
    X
    X
    6
    Range.SpecialCells
    X
    X
    X
    X
    X

  19. #19
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Count Contiguous cells only

    Application.OnTime also, methinks.
    Last edited by shg; 09-16-2015 at 01:31 PM.

+ 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] AutoFill down non contigous Columns
    By Rikkdh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2013, 10:06 AM
  2. Paste into non contigous Cells
    By HangMan in forum Excel General
    Replies: 1
    Last Post: 12-18-2012, 02:13 PM
  3. Using Concatenate and a non contigous list
    By scaffdog845 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-01-2008, 12:43 PM
  4. [SOLVED] ListBox with non contigous columns
    By François in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2006, 11:10 AM
  5. XIRR with non contigous cells
    By topola in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-22-2005, 04:30 AM
  6. Replies: 2
    Last Post: 04-16-2005, 03:02 PM
  7. Substracting Numbers in non contigous cells
    By Guillermo Padro in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-13-2005, 10:38 AM
  8. substracting numbers in non contigous cells
    By Guillermo Padrón in forum Excel General
    Replies: 5
    Last Post: 04-10-2005, 09:06 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