View Single Post
  #2   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Changing the contents of a cell... dynamically?

Hi
you can use the worksheet_change event for this kind of operation. Put
the following code in your worksheet module:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Target, Me.Range("A10")) Is Nothing Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo CleanUp
With Target
If .Value < "" Then
Application.EnableEvents = False
.Value = .Value - 25
End If
End With

CleanUp:
Application.EnableEvents = True
End Sub

HTH
Frank

Friendly Indián wrote:
I am wanting to do something that I don't know if it is
possible. Here is the scenario...

Say cell A10 gets data (numbers) entered into it, for this
example lets say 100, after the focus moves from the cell I want
25 to be automatically subtracted from the number so that it is
actually is 75. How can I do this if it is possible? Thanks.