View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
jtp jtp is offline
external usenet poster
 
Posts: 1
Default A little advice on comparing cells


I think I have an understanding of what your looking for. I'm by n
means a pro at Excel but, this does work. I put the time stamp i
column F (basically beside the 1) and the current +/- goal in column G
It subtracts the persons actual transactions in column E from the goa
in column B. Sums them all up to show if they are over/under at th
current time. Place the code in the current worksheet object.

-Private updated As Boolean, thisTime As Date

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count = 1 And Target.Column = 6 And Target.Value = 1 Then
thisTime = Right(Now(), (Len(Now()) - InStr(Now(), " ")))
updated = True
Target.Offset(0, 1).Value = thisTime
ElseIf updated = True Then
Target.Offset(0, 1).Value = CompareColumns(thisTime)
End If

End Sub

Private Function CompareColumns(thisTime As Date)
Dim cell As Range, totalCounts%

'Now start comparing
Set cell = Range("A2")

While cell.Value <= thisTime And cell.Value < ""
CompareColumns = CompareColumns + (cell.Offset(0, 4).Value
cell.Offset(0, 1).Value)
Set cell = cell.Offset(1, 0)
Wend
updated = False
End Function-

Without a doubt there is a better way to do it but this was the quic
and easy way. Hope this helps and good luck,

Jaso

--
jt
-----------------------------------------------------------------------
jtp's Profile: http://www.excelforum.com/member.php...fo&userid=2113
View this thread: http://www.excelforum.com/showthread.php?threadid=49586