+ Reply to Thread
Results 1 to 9 of 9

Formula to return number of cells lapsed after specific reading occurred

  1. #1
    Registered User
    Join Date
    05-04-2018
    Location
    Hong Kong
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    69

    Formula to return number of cells lapsed after specific reading occurred

    Dear Sir

    Please refer to the enclosed spreadsheet and suggest a formula to return value in row 40

    Thanks!
    Attached Files Attached Files

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

    Re: Formula to return number of cells lapsed after specific reading occurred

    Please try at After

    D40 copy to the right
    =IFERROR(ROWS(D1:D37)-MATCH(2,INDEX(1/D1:D37,)),)

    D41 copy to the right
    =IFERROR(ROWS(D1:D37)-MATCH(1,INDEX((ROW($E$1:$E$37)>MATCH(2,INDEX(1/D1:D37,)))/(E1:E37>0),),),)
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-04-2018
    Location
    Hong Kong
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    69

    Re: Formula to return number of cells lapsed after specific reading occurred

    Hi
    Apologies for the delay in reply.
    I have tested the suggested formula with real data and it seem to work.
    However as data are updated, the formula did not cater for that.
    I have incorporated the formula in the accompanying revised excel and explained the issue.
    Appreciate any further input.
    Thanks a lot!
    Attached Files Attached Files

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

    Re: Formula to return number of cells lapsed after specific reading occurred

    Please try at sheet After

    D40
    =IFERROR(ROWS(D1:D38)-MATCH(2,INDEX(1/D1:D38/(ROW(D1:D38)<>ROWS(D1:D38)),))-1,)

    D41
    =IFERROR(ROWS(D1:D38)-1-MATCH(1,INDEX((ROW(D1:D38)>MATCH(2,INDEX(1/D1:D38/(ROW(D1:D38)<>ROWS(D1:D38)),)))/(OFFSET(D1:D38,,SIGN(MOD(COLUMNS($D40:D40)-2,3)-1.5))>0)/(ROW(D1:D38)<>ROWS(D1:D38)),),),)

    Copy both to the right.

    The formula is cover row 38, you can select row 38 and insert row or press Ctrl + when you need to add more data.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-04-2018
    Location
    Hong Kong
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    69

    Re: Formula to return number of cells lapsed after specific reading occurred

    Hi

    The formula is brilliant.
    However I do find it difficult to apply in reality, which I explained in the enclosed spreadsheet.
    I am sorry this is getting complicated, and not sure if you want to continue to work on it, but your help so far is much appreciated.
    Attached Files Attached Files

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

    Re: Formula to return number of cells lapsed after specific reading occurred

    The formula in post#4 is to compare a group with 2 columns and 1 empty column between each group,
    That where I use this "SIGN(MOD(COLUMNS($D40:D40)-2,3) -1.5))" for use the same formula to copy to the right.

    Now you want to compare a group with 4 columns with no space column in between, that changes everything.



    Group A

    1 and 34 are companion numbers
    24 and 26 are companion numbers
    Will these changes? compare column D with E and Column C with F ?



    Therefore, can we have a formula that:
    1. Do not always make reference to Column D
    (Since the companion numbers come in pairs, can the formula reference to only its own column and that of the companion number, rather than always Column D)
    Yes. I use column D because it is the first column for formula in post#4, might change to column C.


    2. Preferrably trace from bottom up rather than from the first row (because in reality there are thousands of readings continuously updated)
    We can use 50 rows above current row or maybe less eg C670:C720.

  7. #7
    Registered User
    Join Date
    05-04-2018
    Location
    Hong Kong
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    69

    Re: Formula to return number of cells lapsed after specific reading occurred

    I apologise.

    I was initially setting out the basic scenario because in reality the number groups combination have several variants, so setting all those out will become overly complicated.

    To answer your question:

    1) Most of the number groups have either 2 or 4 numbers, however we are only comparing 2 directly related companion numbers, which as you describe compare column D with E and Column C with F. Only that at this stage, not other columns within the same number group.

    2) In reality, the companion numbers for some number groups are up to 5 to 7 columns apart, with interspersed numbers from other groups in-between. In a few cases, the number of columns apart between companion numbers could be more. However, if the formula reference to only its own column and that of the companion number, possibly I could adapt the formula to accommodate those situations.

    If you are kind enough, would it be possible to cater for scenario 1 for now (which is set out in my spreadsheet in post #5), and I see whether can adapt the formula to the other scenario.

    Many thanks!

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

    Re: Formula to return number of cells lapsed after specific reading occurred

    Please try at C722

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    =(OFFSET(C671:C720,,-(MOD(COLUMNS($C1:C1)-1,4)-1.5)*2)
    This is use for find companion column

    =-(MOD(COLUMNS($C1:C1)-1,4)-1.5)*2 copy to the right gives 3, 1, -1, -3, 3, 1, -1, -3

    =(OFFSET(C671:C720,,3) = F671:F720
    =(OFFSET(D671:D720,,1) = E671:E720
    =(OFFSET(E671:E720,,-1) = D671:D720
    =(OFFSET(F671:F720,,-3) = C671:C720
    =(OFFSET(G671:G720,,3) = J671:J720 and so on every 4 columns

    Similar to =OFFSET(C721,,-MOD(COLUMNS($C1:C1)-1,4),,4))
    This is used for find No. of cells lapsed since last reading of each group.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    05-04-2018
    Location
    Hong Kong
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    69

    Re: Formula to return number of cells lapsed after specific reading occurred

    Thank you very much!
    The formula for the two adjacent numbers (1,34 in Group A / 4,31 in Group B) seem to work.
    I am not good enough to understand how it works but think I can hire someone to adapt the formula for other scenarios.
    Very helpful

+ 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] return the number of cells with the most consecutive specific values.
    By Bab1 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-13-2014, 07:11 AM
  2. Formula for a range of cells with a certain value to return a specific cell
    By kajjampur in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-05-2013, 06:24 PM
  3. Replies: 4
    Last Post: 04-21-2013, 01:09 PM
  4. [SOLVED] Formula to Return data in specific cells
    By headley4ever in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-04-2013, 01:09 PM
  5. Three if statements to calculate number of days lapsed
    By janetk411 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-25-2012, 03:55 PM
  6. How do I return first year that expenditure occurred?
    By LinnyLoo in forum Excel General
    Replies: 4
    Last Post: 06-14-2012, 08:21 AM
  7. return data which occurred in a period
    By easty in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 08-06-2010, 10:19 PM

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