View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
mudraker[_378_] mudraker[_378_] is offline
external usenet poster
 
Posts: 1
Default Request macro code - when cell change event


You need several change event macros as you need to be able to track the
value of a1 from the time the workbook is opend or the sheet is
activated

try these 3

copy and paste all on to the module for your sheet

Option Explicit

Dim iA1 As Integer

Private Sub Worksheet_Activate()
If Target.Address = "$A$1" Then
iA1 = Range("a1").Value
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
Dim iDif As Integer
If Target.Address = "$A$1" Then
If iA1 < Target.Value Then
Application.EnableEvents = False
iDif = Target.Value - iA1
Range("a2").Value = Range("a2").Value + iDif
Range("a3").Value = Range("a3").Value + iDif
End If
iA1 = Target.Value
End If
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then
iA1 = Range("a1").Value
End If
End Sub


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=537685