+ Reply to Thread
Results 1 to 15 of 15

Formula to Output Result Based on Consecutive Cells Containing X

  1. #1
    Registered User
    Join Date
    01-25-2019
    Location
    Charlotte
    MS-Off Ver
    2011
    Posts
    8

    Formula to Output Result Based on Consecutive Cells Containing X

    Hello everyone,

    I am new to this forum, apologies if this has been posted before.

    I am looking for a formula for the below:

    Scenario one: Let's say A1 is populated, A2 is populated, A3 is blank and A4 is populated and A5 is populated. I am looking for a formula that will output a value of 2 in cell A6. Basically looking for an output that only takes into consideration consecutive cells.

    Another scenario: B1 is blank, B2 is populated, B3 is populated, B4 is populated, B5 is blank. I am looking for an output of 2 since there are two consecutives (B2, B3 and B3, B4)

    Just as an fyi, I am populating these cells with an insert symbol function of 'X'.


    Thanks in advance!
    Last edited by AliGW; 01-25-2019 at 04:52 PM.

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

    Re: Formula to Output Result Based on Consecutive Cells Contining X

    Welcome to the forum!

    Your thread title does not comply with the forum rules, so I have changed it for you this time. Please make sure that you use more explicit thread titles in future. Thanks!
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Please try at A6 and drag to the right
    =sumproduct((a1:a4<>"")*(a1:a4=a2:a5))

  4. #4
    Registered User
    Join Date
    01-25-2019
    Location
    Charlotte
    MS-Off Ver
    2011
    Posts
    8

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Thank you so much! This works like magic. Can you help explain the logic behind the formula?

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Data in A1:A5

    a. (a1:a4<>"") give 4 values of True False, True if not blank
    b. (a1:a4=a2:a5) check a1=a2, … ,a4=a5 give 4 values of True False, True if cell and cell next row has the same value
    c. (a1:a4<>"")*(a1:a4=a2:a5) give 4 values of (True,False)*(True,False) True if not blank and ell and cell next row has the same value. True*True = 1, True*False = 0

    Sumproduct(c.) for count only True*True

  6. #6
    Registered User
    Join Date
    01-25-2019
    Location
    Charlotte
    MS-Off Ver
    2011
    Posts
    8

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    You are great, thanks so much!

    While working on the same project, I also stumbled upon the doubt below:

    Is there anyway to look at two columns in excel to highlight duplicates? Usually we all look at just one column or one row to highlight duplicates from Conditional Formatting.

    For example:
    In cell A1, I have text that says ‘Group 1’ and in cell B1, I have text that says ‘Joe’.
    I do not want this to flag if I type ‘Group 1’ in A2 and ‘Mary’ in B2.
    I want both A3 and B3 to be flagged if I type ‘Group 1’ in A3 and ‘Joe’ in B3

    Can you please tell me if there is a formula that I can enter in New rule under Conditional Formatting for this? Thank you again for all your help!

  7. #7
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Could you please upload your file > Go Advanced > Manage Attachments

  8. #8
    Registered User
    Join Date
    01-25-2019
    Location
    Charlotte
    MS-Off Ver
    2011
    Posts
    8

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Absolutely, I just did. Please let me know if you are able to view it!
    Attached Files Attached Files

  9. #9
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Please try CF formula applies to A1:B11

    =COUNTIFS($A$1:$A1,$A1,$B$1:$B1,$B1)>1
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    01-25-2019
    Location
    Charlotte
    MS-Off Ver
    2011
    Posts
    8

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    You are the best!

  11. #11
    Registered User
    Join Date
    01-25-2019
    Location
    Charlotte
    MS-Off Ver
    2011
    Posts
    8

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Hey Bo_Ry! Thanks again for your help yesterday. I believe this could be the last piece of the puzzle for my project thanks to you.
    In the attached file, can you help me with the formula to highlight consecutive duplicate cells (including the first occurrence) ignoring the blank cells? I have defined my criteria in Column S for the respective rows.

    Edit:

    For Row 1: I need I1 and J1 highlighted
    For Row 2: I need E2 highlighted as well along with the rest
    For Row 3: I need F3 highlighted as well along with the rest
    Attached Files Attached Files
    Last edited by apk120490; 01-29-2019 at 11:11 AM.

  12. #12
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Please try CF formula applies to E1:Q9

    =(D1=E1)*(E1="✖")
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    01-25-2019
    Location
    Charlotte
    MS-Off Ver
    2011
    Posts
    8

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Thank you! Can you let me know if I want to highlight the first (original) occurrence as well?

    For Row 1: I1 and J1 highlighted
    For Row 2: E2 highlighted as well along with the rest
    For Row 3: F3 highlighted as well along with the rest

  14. #14
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Try
    =((D1=E1)+(E1=F1))*(E1="✖")

  15. #15
    Registered User
    Join Date
    01-25-2019
    Location
    Charlotte
    MS-Off Ver
    2011
    Posts
    8

    Re: Formula to Output Result Based on Consecutive Cells Containing X

    Thanks so much again!

+ 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. Replies: 3
    Last Post: 01-10-2019, 09:34 AM
  2. Replies: 5
    Last Post: 02-16-2018, 06:50 AM
  3. Replies: 8
    Last Post: 09-22-2017, 05:41 AM
  4. Excel formula bar to display the result of the formula , not the formula?
    By max_max in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2016, 07:15 PM
  5. Replies: 11
    Last Post: 06-06-2014, 03:34 PM
  6. how to hide formula in formula box, view lookup result in formula box?
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 04:06 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