View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
cliff18 cliff18 is offline
external usenet poster
 
Posts: 16
Default Maintaining a cells value once a target is achieved

Thanks Max, what you gave me worked perfectly, including reloading the
formula with the Macro!
The only thing I didn't mention is that I would like this formula to work
all the way down from row 7 (as in the formula I sent) down to row 20. I
thought I could work it out myself with what you gave me, but unfortunatley I
am just getting errors as I change the range as below.
'------
Private Sub Worksheet_Calculate()
If Range("M7:M20").Value = "Yes" Then
Range("M7:M20").Value = Range("M7:M20").Value
End If
End Sub
'-----

Sorry to ask again but is it possible to get this to work in this way.
--
Cheers
cliff18


"Max" wrote:

Try this on a spare copy

Right-click the sheet tab choose "View Code"
Copy n paste the sub below into the code window (white space on right)
Press Alt+Q to get back to Excel
Test it out ...

'------
Private Sub Worksheet_Calculate()
If Range("M7").Value = "Yes" Then
Range("M7").Value = Range("M7").Value
End If
End Sub
'-----

And to re-instate the formula in M7 later (when it doesn't evaluate to
"Yes"), you could install the sub below in a regular module*, then run it in
Excel, via say, the Macro dialog (press Alt+F8)
*press Alt+F11 to go to VBE, click InsertModule, copy n paste

Sub Put_In_M1()
Range("M7").FormulaR1C1 = _
"=IF(AND(RC[5]=""H"",(RC[-9]<=((RC[7]-RC[8])/2+RC[8]))),""Yes"","""")"
End Sub
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:22,000 Files:370 Subscribers:66
xdemechanik
---
"cliff18" wrote:
I use Excel 2003.
I import changing data into one cell 'D7' in the form of a number. I use
information from other cells 'R7,T7,U7' to give me a target, and once the
target is achieved, the text "Yes" is automatically printed in another cell
'M7'.
I have been able to make this work ok using the formula below, but
unfortunately once the figure rises above the target again, the text
disappears.
Does anyone know of a way that I can make the text remain in the cell once
the target is achieved until I manually reset it.
=IF(AND(R7="H",(D7<=((T7-U7)/2+U7))),"Yes","")