close

Hi,

Here is the setup:
I get streaming data in cell g2. I want to compare this data with the
previous data in this cell so I copy the old data in cell g3. If G3 is
4 points less I must send a string to a api system to buy stock.

This is what I came up with:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Range(quot;g2quot;) lt; Range(quot;g3quot;) - 4 Then
Range(quot;c10quot;) = Range(quot;c10quot;) 1 (lt;= this where the string should be.
NOW TESTING )
Range(quot;g3quot;) = Range(quot;g2quot;)
Range(quot;g3quot;) = Range(quot;g3quot;)
End If

End SubThis works but only when I click on the sheet when G2 changes.
I tried to put it in a macro with loop but then my streaming data
doesn´t work.
I am a newbee so please can sommeone help me on the right track?

Thanks--
climax
------------------------------------------------------------------------
climax's Profile: www.excelforum.com/member.php...oamp;userid=30816
View this thread: www.excelforum.com/showthread...hreadid=506297Try this

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = quot;G2:G3quot;

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If Me.Range(quot;G2quot;) lt; Me.Range(quot;G3quot;) - 4 Then
Me.Range(quot;C10quot;) = Me.Range(quot;C10quot;) 1
Me.Range(quot;gG3quot;) = Me.Range(quot;G2quot;)
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

quot;climaxquot; gt; wrote in
message ...
gt;
gt; Hi,
gt;
gt; Here is the setup:
gt; I get streaming data in cell g2. I want to compare this data with the
gt; previous data in this cell so I copy the old data in cell g3. If G3 is
gt; 4 points less I must send a string to a api system to buy stock.
gt;
gt; This is what I came up with:
gt;
gt; Private Sub Worksheet_SelectionChange(ByVal Target As Range)
gt;
gt; If Range(quot;g2quot;) lt; Range(quot;g3quot;) - 4 Then
gt; Range(quot;c10quot;) = Range(quot;c10quot;) 1 (lt;= this where the string should be.
gt; NOW TESTING )
gt; Range(quot;g3quot;) = Range(quot;g2quot;)
gt; Range(quot;g3quot;) = Range(quot;g3quot;)
gt; End If
gt;
gt; End Sub
gt;
gt;
gt; This works but only when I click on the sheet when G2 changes.
gt; I tried to put it in a macro with loop but then my streaming data
gt; doesn´t work.
gt; I am a newbee so please can sommeone help me on the right track?
gt;
gt; Thanks
gt;
gt;
gt; --
gt; climax
gt; ------------------------------------------------------------------------
gt; climax's Profile:
www.excelforum.com/member.php...oamp;userid=30816
gt; View this thread: www.excelforum.com/showthread...hreadid=506297
gt;

Thanks
My straeming data in cell g2 works ok, but cell g3 doesn´t change so it
can´t compare old with new data. Cell c10 works ok ( Tried it by
entering higher value in g3 )--
climax
------------------------------------------------------------------------
climax's Profile: www.excelforum.com/member.php...oamp;userid=30816
View this thread: www.excelforum.com/showthread...hreadid=506297

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()