Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rounding Logic Question

Hello.

I am trying to work out a method for rounding prices to specific price
points.

Say for example I enter a price into cell D1, I want the cell E1 to
search through the range to find what the appropriate rounded value
should be.
Take the following 3 columns - if the price is between A and B, I want
the value from C.

I can do this using a messy formula nesting IF and AND functions for a
small range, something like
=IF(AND($D$1<=B1,$D$1=A1),C1,IF(AND($D$1<=B2,$D$1 =A2),C2,"error"))
but I get stumped quickly because the range will have approx 150 rows.

A B C
1.08 1.34 1.29
1.35 1.55 1.49
1.56 1.80 1.79
1.81 2.07 1.99
2.08 2.34 2.29
etc.

I'd like this solution to be availabe for multiple workbooks but I'm
not familiar with macros very much.

Thanks and regards,
Mark.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rounding Logic Question

Sorry, forgot to mention Excel version 200

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Rounding Logic Question

Hi Mark,

Always be very prcise as to what you want the borders to be.
In your case, the second column seems to be superfluous.
With the value to be looked up in D2, and your table in A1:C6, use this
formula:

=VLOOKUP(D2,$A$2:$C$6,3)

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel


"licksy " wrote in message
...
Hello.

I am trying to work out a method for rounding prices to specific price
points.

Say for example I enter a price into cell D1, I want the cell E1 to
search through the range to find what the appropriate rounded value
should be.
Take the following 3 columns - if the price is between A and B, I want
the value from C.

I can do this using a messy formula nesting IF and AND functions for a
small range, something like
=IF(AND($D$1<=B1,$D$1=A1),C1,IF(AND($D$1<=B2,$D$1 =A2),C2,"error"))
but I get stumped quickly because the range will have approx 150 rows.

A B C
1.08 1.34 1.29
1.35 1.55 1.49
1.56 1.80 1.79
1.81 2.07 1.99
2.08 2.34 2.29
etc.

I'd like this solution to be availabe for multiple workbooks but I'm
not familiar with macros very much.

Thanks and regards,
Mark.


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Rounding Logic Question

Mark

'One option is a user defined function to use as a formula
'For example in the function below
'price is the value in col D
'rounded_range is the range in col C
'place the function in col E, make the rounded range absolute $
'and copy down 150 rows

Function Round_Value(price, Rounded_Range)
Application.Volatile
Round_Value = "error"
For Each cell In Rounded_Range 'all data cells col C

Select Case cell.Offset(0, -2) 'compare col A
Case Is <= price
If cell.Offset(0, -1) = price Then 'compare col B
Round_Value = cell.Value
Exit Function
End If
End Select
Next
End Function

HTH

Mike B
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logic question palhota Excel Worksheet Functions 5 October 20th 08 08:01 PM
Check box logic question Ailsa02 Excel Worksheet Functions 4 August 23rd 08 04:04 PM
IF(?) logic question Dave Excel Discussion (Misc queries) 3 February 10th 07 12:28 PM
Logic question ACDenver Excel Discussion (Misc queries) 1 August 16th 05 04:29 AM
Logic Question - Can you help please Leo Heuser[_2_] Excel Programming 0 July 16th 03 03:30 PM


All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"