View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Harold Shea Harold Shea is offline
external usenet poster
 
Posts: 11
Default Converting Formulas to Hard Values and Vice Versa?

Dave: See my reply to Simon, just above. Thanks!

"Dave Peterson" wrote:

Lightly tested:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRng As Range
Dim myCell As Range
Dim RngToInspect As Range

Set RngToInspect = Me.Range("F1").EntireColumn

Set myRng = Nothing
On Error Resume Next
Set myRng = Intersect(Target, RngToInspect)
On Error GoTo 0

If myRng Is Nothing Then
Exit Sub 'nothing changed in column F
End If

On Error GoTo ErrHandler:

Application.EnableEvents = False
For Each myCell In myRng.Cells
With myCell
Select Case LCase(.Value)
Case Is = LCase("Firm")
Me.Cells(.Row, "O").Value = Me.Cells(.Row, "O").Value
Me.Cells(.Row, "p").Value = Me.Cells(.Row, "p").Value
Me.Cells(.Row, "q").Value = Me.Cells(.Row, "q").Value
Case Is = LCase("Tentative")
Me.Cells(.Row, "O").Formula = "=Column_O_Calc"
Me.Cells(.Row, "p").Formula = "=Column_P_Calc"
Me.Cells(.Row, "q").Formula = "=Column_Q_Calc"
End Select
End With
Next myCell

ErrHandler:
Application.EnableEvents = True

End Sub


Harold Shea wrote:

I have a large spreadsheet which is updated with order statuses on a weekly
basis. Each row shows a different order. In Column E is the current status of
each order: "Firm" or "Tentative." In Columns O, P, and Q are formulas that
calculate various milestone dates for the order. These dates recalculate
throughout the life cycle of the order, but once the order status in Column F
turns to FIRM, these dates are frozen. Is there a way to use a
Worksheet_Change event to read the statuses in Column F and, when one changes
to FIRM, to replace the values in Columns O, P, and Q on that row with
whatever their current values are? And is the reverse possible in case a use
makes an error? You know, if a status changes back to TENTATIVE, for the
formulas in O, P, and Q to restore to formulas? (I've given the formulas
names "Column_O_Calc", "Column_P_Calc", and "Column_Q_Calc")

Users can do all of this manually, but the problem is that the sheet is a
couple of thousand lines long and the updates numerous. To complicate things,
the status info in Column F can be imported into the sheet from Oracle OR
manually changed by users, so any macro would have to respond to cell changes
in either case.

I'd really appreciate any help anyone can offer.


--

Dave Peterson