Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I create a cell whose value can only go up, not down?

Hi

I have a formula in a cell currently, that is based on the value i
another cell. As the value in the other cell increases I want th
formula to be in effect and continue to calculate increasing values

However, if the value in the other cell goes down, I no longer wan
this formula to do anything, ie. the value it last calculated remain
in effect

For your information this is to create a rising stop loss in an exce
portfolio. Hence the price may go up or down, but the stop los
limit must only continue to rise

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How do I create a cell whose value can only go up, not down?

This could do with event disabling to stop unnecessary re-entry, error
handling, and testing for the target range

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo ws_exit
If Target.Address = "$C$2" Then
If Target.Value Range("C1").Value Then
Range("c1").Value = Target.Value
End If
End If
ws_exit:
Application.EnableEvents = True
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Don Guillett" wrote in message
...
right click on the sheet tabview codecopy/paste this.modify ranges to

suit

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("c2") < Range("c1") Then Exit Sub
Range("c1").Value = Range("c2")
End Sub

--
Don Guillett
SalesAid Software

"icehot" wrote in message
...
Hi,

I have a formula in a cell currently, that is based on the value in
another cell. As the value in the other cell increases I want the
formula to be in effect and continue to calculate increasing values.

However, if the value in the other cell goes down, I no longer want
this formula to do anything, ie. the value it last calculated remains
in effect.

For your information this is to create a rising stop loss in an excel
portfolio. Hence the price may go up or down, but the stop loss
limit must only continue to rise.

Thanks,





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default How do I create a cell whose value can only go up, not down?

right click on the sheet tabview codecopy/paste this.modify ranges to suit

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("c2") < Range("c1") Then Exit Sub
Range("c1").Value = Range("c2")
End Sub

--
Don Guillett
SalesAid Software

"icehot" wrote in message
...
Hi,

I have a formula in a cell currently, that is based on the value in
another cell. As the value in the other cell increases I want the
formula to be in effect and continue to calculate increasing values.

However, if the value in the other cell goes down, I no longer want
this formula to do anything, ie. the value it last calculated remains
in effect.

For your information this is to create a rising stop loss in an excel
portfolio. Hence the price may go up or down, but the stop loss
limit must only continue to rise.

Thanks,



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I create a cell whose value can only go up, not down?

if you want a formula, you need to create an intentional circular reference.

You would have to go to tools=Options, then under the calculate tab, select
iterate and set maximum iterations to 1.

then you can create an intentional circular reference

In B1 (refering to A1) for instance use a formula like:

=if(A1="",0,if(A1 B1,A1,B1))

the disadvantage with this is that if you improperly create a formula that
has a circular reference, you will not be warned.

Note that this is an application level setting and might have to be set each
time you open the workbook to avoid the warning (or whenever it gets
changed).

--
Regards,
Tom Ogilvy


"icehot" wrote in message
...
Hi,

I have a formula in a cell currently, that is based on the value in
another cell. As the value in the other cell increases I want the
formula to be in effect and continue to calculate increasing values.

However, if the value in the other cell goes down, I no longer want
this formula to do anything, ie. the value it last calculated remains
in effect.

For your information this is to create a rising stop loss in an excel
portfolio. Hence the price may go up or down, but the stop loss
limit must only continue to rise.

Thanks,



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default How do I create a cell whose value can only go up, not down?

If c1 is the cell with changing values, and c2 holds the value, then you
can use c1's change event to increase the value in c2.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$1" Then
If Target.Value Range("C2").Value Then
Range("C2").Value = Target.Value
End If
End Sub

Patrick Molloy
Microsoft Excel MVP
"icehot" wrote in message
...
Hi,

I have a formula in a cell currently, that is based on the value in
another cell. As the value in the other cell increases I want the
formula to be in effect and continue to calculate increasing values.

However, if the value in the other cell goes down, I no longer want
this formula to do anything, ie. the value it last calculated remains
in effect.

For your information this is to create a rising stop loss in an excel
portfolio. Hence the price may go up or down, but the stop loss
limit must only continue to rise.

Thanks,



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
can i create formula to make cell PLURAL if other cell is 1? me@BBB Excel Worksheet Functions 6 July 24th 08 09:18 PM
Create Cell Comment based on text in a cell on another worksheet Dave Fellman Excel Discussion (Misc queries) 2 March 15th 07 09:49 AM
How to create table of cell names with the name's cell address WildwoodEngr Excel Discussion (Misc queries) 1 October 26th 06 02:52 PM
How to create/run "cell A equals Cell B put Cell C info in Cell D abmb161 Excel Discussion (Misc queries) 5 January 26th 06 06:36 PM
Excel - create button to replace cell content with cell value blackmot Excel Worksheet Functions 3 December 7th 05 05:10 PM


All times are GMT +1. The time now is 05:29 AM.

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"