PC Review


Reply
Thread Tools Rate Thread

Calculation based on changing conditions

 
 
xsrossiter
Guest
Posts: n/a
 
      28th Aug 2010
Hello,

I am using Excel 2002 SP3 and hope to find a conditional solution
using formulas rather than a macro. In column A are a series of
values, column B has values at irregular intervals, and column C
contains calculated values based on a value in column B until a new
value in column B is encountered and then it incorporates the new
column B value in its calculation.

A B C
2 3 5
6 9
8 11
4 2 6
15 17
8 10
21 8 29

For example, column C contains a formula to sum columns A and B. It
adds 3 to whatever value is in column A until the fourth row at which
point it adds 2 to whatever value is in the A column and finally as it
gets to the seventh row begins adding 8 to A column values.

Is there some formula that can be placed in column C that will follow
this logic and avoid using a macro? Column A at this point has 86 rows
and column B has 14 values at varying intervals.

Thanks for your help and time.

Steve
 
Reply With Quote
 
 
 
 
transkawa
Guest
Posts: n/a
 
      27th Sep 2010
In article <(E-Mail Removed)>, (E-Mail Removed)
says...
>
> On Sat, 28 Aug 2010 00:45:45 -0700 (PDT), xsrossiter
> <(E-Mail Removed)> wrote:
>
> >Hello,
> >
> >I am using Excel 2002 SP3 and hope to find a conditional solution
> >using formulas rather than a macro. In column A are a series of
> >values, column B has values at irregular intervals, and column C
> >contains calculated values based on a value in column B until a new
> >value in column B is encountered and then it incorporates the new
> >column B value in its calculation.
> >
> > A B C
> > 2 3 5
> > 6 9
> > 8 11
> > 4 2 6
> > 15 17
> > 8 10
> > 21 8 29
> >
> >For example, column C contains a formula to sum columns A and B. It
> >adds 3 to whatever value is in column A until the fourth row at which
> >point it adds 2 to whatever value is in the A column and finally as it
> >gets to the seventh row begins adding 8 to A column values.
> >
> >Is there some formula that can be placed in column C that will follow
> >this logic and avoid using a macro? Column A at this point has 86 rows
> >and column B has 14 values at varying intervals.
> >
> >Thanks for your help and time.
> >
> >Steve

>
> If your data starts in A1:
>
> C1: =A1+LOOKUP(1E+307,$B$1:B1)
>
> and fill down as far as required.


I carried out your lookup() function, both for the array and the vector
form and it didn't work out as specified. I think the help files say the
lookup() function requires the lookup_vector be in ascending order for a
reliable result also although it is not a necessity.
My C1 returned FALSE instead of a numerical value.

--
Never question, keep asking
234 702 866 8957
 
Reply With Quote
 
joeu2004
Guest
Posts: n/a
 
      28th Sep 2010
Ron Rosenfeld wrote:
> C1: =A1+LOOKUP(1E+307,$B$1:B1)



On Sep 27, 6:51*am, transkawa <transk...@yahoo.fr> wrote:
> it didn't work out as specified. [....] My C1 returned FALSE instead
> of a numerical value.


Works fine for me, using the example that xsrossiter provided.
Moreover, I do not see how Ron's formula could return FALSE, at least
in Excel 2003, the version I have.

Normally, LOOKUP requires that the lookup vector is in ascending order
because LOOKUP uses a binary search. If you know how a binary search
works, it should be no surprise that LOOKUP(2,{2,1,3,4},{1,2,3,4})
returns 2 undesirably, and LOOKUP(1,{2,1,5,3,4},{1,2,3,4,5}) returns
#N/A.

But Ron's LOOKUP(1E307,...) relies on an accident of implementation,
namely: the binary search should always gravitate to the largest
number in the lookup vector, even if the lookup vector is not in
ascending order.

If you have a counter-example, I hope that you will post all the
details.
 
Reply With Quote
 
joeu2004
Guest
Posts: n/a
 
      28th Sep 2010
I wrote:
> But Ron's LOOKUP(1E307,...) relies on an accident of implementation,
> namely: *the binary search should always gravitate to the largest
> number in the lookup vector, even if the lookup vector is not in
> ascending order.


..... Because 1E307 is presumably larger than any number in column B.

Of course, there are larger possible numbers. The largest possible
number that can be entered manually is 9.99999999999999E+307. The
largest possible result of a computation is about 1.79769313486232E
+308, exactly (2^1023 - 2^(1023-53))*2.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CALCULATION BASED ON MORE THAN TWO CONDITIONS =?Utf-8?B?RWNsYWlyZXM=?= Microsoft Excel Misc 4 10th Jul 2007 03:30 PM
Changing the color of a cell and adjacent cells based on conditions Matt Microsoft Excel Programming 2 6th Sep 2006 01:34 PM
Use different formula to calculation based on conditions 0-0 Wai Wai ^-^ Microsoft Excel Misc 2 3rd Dec 2005 08:28 AM
Formula for calculation based on multiple conditions hforman Microsoft Excel Worksheet Functions 0 4th Oct 2004 07:22 PM
Formula for calculation based on multiple conditions hforman Microsoft Excel Worksheet Functions 2 4th Oct 2004 05:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:58 AM.