In desperate need of help!

breakbacktennis

New Member
Joined
Aug 30, 2017
Messages
33
Hi, Im in desperate need of help with this VBA code. The code works fine when entered manually however I need the code to work when linked with a live feed.

Code:
[COLOR=#333333]Private Sub Worksheet_Change(ByVal Target As Range)[/COLOR]    Dim KeyCells As Range




   If Target.Address <> Range("G1").Address Then Exit Sub
    


        If Range("G1").Value = "In-play" Then
               Range("U9").Value = Range("G9").Value
               Range("U11").Value = Range("G11").Value
        End If

 [COLOR=#333333]End Sub[/COLOR]
 
So it sounds like it is working as programmed... it's just that you only want to keep the first transition from not in play to in play... does that sound correct?
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
So it sounds like it is working as programmed... it's just that you only want to keep the first transition from not in play to in play... does that sound correct?

Spot on Ninja, when In-play appears the values that should appear do but then they are refreshed, so it is working but i just want that first transition as u state.
 
Upvote 0
If you don't want to have it continue to update, simply take out the else condition that resets the Boolean:

Code:
Private Sub Worksheet_Calculate()
Application.EnableEvents = False
    If Range("G1").Value = "In-play" And bIsInTarget = False Then
           Range("U9").Value = Range("G9").Value
           Range("U11").Value = Range("G11").Value
           bIsInTarget = True
    End If
    
Application.EnableEvents = True
End Sub

That should fix it...

Good luck,

CN.

*** Post Note: If you close the workbook and re-open, it will again update. If you don't want that to happen, then you need to change the Boolean to something like have I updated today... Store the last update date somewhere and set your Boolean by that value as compared to today(). If you want that, let me know... ***
 
Last edited:
Upvote 0
If you don't want to have it continue to update, simply take out the else condition that resets the Boolean:

Code:
Private Sub Worksheet_Calculate()
Application.EnableEvents = False
    If Range("G1").Value = "In-play" And bIsInTarget = False Then
           Range("U9").Value = Range("G9").Value
           Range("U11").Value = Range("G11").Value
           bIsInTarget = True
    End If
    
Application.EnableEvents = True
End Sub

That should fix it...

Good luck,

CN.

*** Post Note: If you close the workbook and re-open, it will again update. If you don't want that to happen, then you need to change the Boolean to something like have I updated today... Store the last update date somewhere and set your Boolean by that value as compared to today(). If you want that, let me know... ***


Well CN i cant believe uv not had enough cus I have lol. Still not working. Works when i manually input In-play though :(, just cant seem to get what it is. You have been a massive help though CN
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top