+ Reply to Thread
Results 1 to 11 of 11

Range of formula changes according to a condition

  1. #1
    Forum Contributor
    Join Date
    10-26-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2013
    Posts
    248

    Range of formula changes according to a condition

    Hi. The formula STDEV.P(B2:$B$22) calculates the standard deviation of the range b2:b22. This formula works great until row 21. The problem is that in row 22 I would like it to calculate the stdev of range (B22:$B$42) and not B22:B22.
    Now, I will try to explain where B42 comes from. Column E has dates. Between E2 and E21 there is the same date. It changes in E22 and stays the same until E41. It changes again in E42. So every time the date in cell E changes I would like this to be the new end row of the range B2:$B$X, where X is the row that the date in cell E changes.
    A table to understand. G is the end result
    row\column B E G
    2 11 14/2/2006 =STDEV.P(B2:$B$22)
    3 12 14/2/2006 =STDEV.P(B3:$B$22)
    4 10 14/2/2006 =STDEV.P(B4:$B$22)
    ... 14/2/2006
    21 13 14/2/2006 =STDEV.P(B21:$B$22)
    22 14 14/3/2006 =STDEV.P(B22:$B$42)
    ... 14/3/2006
    41 11 14/3/2006 =STDEV.P(B41:$B$42)
    42 10 18/4/2006 =STDEV.P(B42:$B$67)
    G42 has $B$67 because in E67 the date is not 18/4/2006.

    Hope you understand what I'm trying to do!
    Thanks for any help!

    P.S.: I have also posted this problem here https://www.mrexcel.com/forum/excel-...condition.html

  2. #2
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Range of formula changes according to a condition

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

  3. #3
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Range of formula changes according to a condition

    Hi all- Perhaps this ARRAY FORMULA in G2:
    Please Login or Register  to view this content.
    Last edited by leelnich; 11-30-2017 at 12:10 PM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  4. #4
    Forum Contributor
    Join Date
    10-26-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2013
    Posts
    248

    Re: Range of formula changes according to a condition

    Quote Originally Posted by José Augusto View Post
    Try this formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thank you for your effort Jose. The problem is that your formula for example in row 7 computes stdev.p of B2:B7 not B7:B22. Do you know how can I fix it please?

  5. #5
    Forum Contributor
    Join Date
    10-26-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2013
    Posts
    248

    Re: Range of formula changes according to a condition

    Quote Originally Posted by leelnich View Post
    Hi all- Perhaps this ARRAY FORMULA in G2:
    Please Login or Register  to view this content.
    Thank you leelnich! Your formula finds the stdev of the data of the row I'm in until 1000. The problem is that 1000 needs to change.

  6. #6
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Range of formula changes according to a condition

    My first effort (post#3) handled row 1 incorrectly, but this ARRAY FORMULA* should work:
    Please Login or Register  to view this content.
    *Always press CTRL+SHIFT+ENTER to confirm entry after pasting or editing an ARRAY FORMULA in the Formula Bar.
    When copying the formula to other cells, make sure the copied cell is not part of the Paste Area.

    Quote Originally Posted by tsakta13ole View Post
    ...The problem is that 1000 needs to change.
    If E1000 has a date, B1000 is part of the final range. Obviously, row 1000 is an arbitrary choice and may be adjusted to suit.
    Last edited by leelnich; 11-30-2017 at 12:49 PM.

  7. #7
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Range of formula changes according to a condition

    I suppose this is what you want
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    (first formula not work well)
    Try that
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by José Augusto; 11-30-2017 at 12:39 PM. Reason: First formula was wrong

  8. #8
    Forum Contributor
    Join Date
    10-26-2013
    Location
    Athens, Greece
    MS-Off Ver
    Excel 2013
    Posts
    248

    Re: Range of formula changes according to a condition

    Thanks for your effort guys! It's none of the above. Sorry. I guess I'm not explaining it well. I will do it manually. It's 10 years but I will be patient!

  9. #9
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Range of formula changes according to a condition

    Hi
    Please, see the file and watch me what is wrong.
    Attached Files Attached Files

  10. #10
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Range of formula changes according to a condition

    One last try at a single-column ARRAY FORMULA. Paste in G2 and copy down:
    Please Login or Register  to view this content.
    Last edited by leelnich; 11-30-2017 at 02:38 PM.

  11. #11
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Range of formula changes according to a condition

    If single formulas don't work, try a helper column (K in this example). Copy from E2 down to cell ABOVE last entry. Select K3 (one cell lower) and paste. Change K2 to match K3. Then paste this ARRAY FORMULA in G2 and copy down:
    Please Login or Register  to view this content.
    Last edited by leelnich; 11-30-2017 at 02:42 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. If a condition is met convert range to value from formula
    By Mothergreen in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-13-2016, 11:49 AM
  2. Need formula using 'If' condition & inserting a specific range.
    By andyzz in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-26-2014, 02:58 AM
  3. [SOLVED] Looping through a range and inserting a formula where condition met
    By strud in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-06-2014, 06:24 AM
  4. Index Formula - adding a range condition
    By Henry c in forum Excel General
    Replies: 2
    Last Post: 04-29-2010, 10:19 AM
  5. formula to calculate the average of a range basing on condition
    By Bob Phillips in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 10:05 AM
  6. formula to calculate the average of a range basing on condition
    By Krishna Mohan in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. formula to calculate the average of a range basing on condition
    By Krishna Mohan in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 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