+ Reply to Thread
Results 1 to 3 of 3

execute once formula

  1. #1
    Registered User
    Join Date
    11-17-2005
    Location
    Georgia
    Posts
    82

    execute once formula

    I have a spreadsheet that monitors a component failure based on several criteria. One column has a formula that enters the date that returns a failure date if the component fails, and leaves the cell blank if the component is functioning normally.

    (Column P contains the following)
    Please Login or Register  to view this content.
    Where N is the column that shows the component has failed and Summary!$B$2 contains the date that the sheet was updated. This works as intended, but I would like the cell to "lose" the formula after it returns a value so that the date will "stick". This way I can track the original failed date even after the component has been repaired.

    I can manually do this by filtering for non-blank cells and copy/paste special (values), but there are about 1500 rows in this spreadsheet and it is updated daily so this is rather cumbersome. The only way that I can think to do this is a circular function (which obviously does not work) ie:

    (Wishful thinking for Column P)
    Please Login or Register  to view this content.
    I have a brain block on how to automate this task, either with a UDF or a VBA Macro (either would be fine)

    Thanks,

    Lee

  2. #2
    K Dales
    Guest

    RE: execute once formula

    Here is one way to do it using the Worksheet_Calculate Event Procedure (you
    can keep the formula in column P the same as you currently have; this will
    just check column P after it calculates and will find the non-blank results,
    will erase the formula and replace it with the value):

    Private Sub Worksheet_Calculate()
    Dim PRange As Range, PCell As Range
    On Error GoTo NoCells
    Set PRange = ActiveSheet.Range("P:P").SpecialCells(xlCellTypeFormulas)
    On Error GoTo 0
    For Each PCell In PRange.Cells
    If PCell.Value <> "" Then PCell.Formula = PCell.Value
    Next PCell
    NoCells:
    End Sub

    --
    - K Dales


    "tekman" wrote:

    >
    > I have a spreadsheet that monitors a component failure based on several
    > criteria. One column has a formula that enters the date that returns a
    > failure date if the component fails, and leaves the cell blank if the
    > component is functioning normally.
    >
    > (Column P contains the following)
    >
    > Code:
    > --------------------
    > =IF(N1="Failed",Summary!$B$2,"")
    > --------------------
    >
    >
    > Where N is the column that shows the component has failed and
    > Summary!$B$2 contains the date that the sheet was updated. This works
    > as intended, but I would like the cell to "lose" the formula after it
    > returns a value so that the date will "stick". This way I can track the
    > original failed date even after the component has been repaired.
    >
    > I can manually do this by filtering for non-blank cells and copy/paste
    > special (values), but there are about 1500 rows in this spreadsheet and
    > it is updated daily so this is rather cumbersome. The only way that I
    > can think to do this is a circular function (which obviously does not
    > work) ie:
    >
    > (Wishful thinking for Column P)
    >
    > Code:
    > --------------------
    > =IF(and(N1="Failed",P1=""),Summary!$B$2,P1)
    > --------------------
    >
    >
    > I have a brain block on how to automate this task, either with a UDF or
    > a VBA Macro (either would be fine)
    >
    > Thanks,
    >
    > Lee
    >
    >
    > --
    > tekman
    > ------------------------------------------------------------------------
    > tekman's Profile: http://www.excelforum.com/member.php...o&userid=28843
    > View this thread: http://www.excelforum.com/showthread...hreadid=491352
    >
    >


  3. #3
    Registered User
    Join Date
    11-17-2005
    Location
    Georgia
    Posts
    82

    Thanks!

    I will play with this one my plane ride this afternoon!!

    Lee

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1