View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default Math formula help

PS: I wrote:
"Robert Crandal" wrote:
Here is a sampling of data that I want to represent with a math formula:
X Y
-- --
0.0 1
0.38 1
0.88 1
1.0 1
1.01 2
1.22 2
1.99 2
2.0 2
2.10 3
2.77 3
3.0 3
etc.. etc..


What about negative X?



"Robert Crandal" wrote:
I prefer a simple math formula that does not use
if-else logic or the less-than or greater-than sybols,
if possible. Let me know if you have any ideas.


If you made a mistake and at X=0, Y should be 0, then perhaps simply:

=ROUNDUP(X1,0)

But that depends on what you want for X<0.

Otherwise, perhaps:

=MAX(1,ROUNDUP(X1,0))

But that assumes for X<0, Y should still be 1.

However, arguably, the use of MAX() is not "simple math that does not use"
IF().


I just realized that you posted to m.p.e.programming. Are you interested in
a VBA expression?

If so, then the first case becomes:

WorksheetFunction.Roundup(X1,0)

and the second case becomes:

IIf(X1<=0,1,WorksheetFunction.Roundup(X1,0))

or

WorksheetFunction.Max(1,WorksheetFunction.Roundup( X1,0))