Hi,
Thanks Osknows,(and Steve) I did manage to play around with the code you sent.
I'm still having the odd problems. There were parts of the original code that I didn't need which I have deleted, I had tested it initially and it basically worked, that is it cleared the cells when it opened. It also worked with the deletion. However it immediately refilled the cells whether the range F5:F40 were above or below '4'., even with the single ref. of F5 being below 4 ??
I have added/changed something more in line with my requirements and also made a couple of cell reference changes. I'll paste below the changes I've made and then explain the current issues I'm having.
Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count = 16 Then
Application.EnableEvents = False
With ThisWorkbook.Sheets(Target.Worksheet.Name)
' Check if the race has just changed and clear any old flags
If CurrentRace <> .Range("A1").Value Then
.Range("AK5:AK35").ClearContents
End If
' Check if a flag must be placed for any BACK bet
' Have assumed your checking if any value in F3:F40 is >=4 ??
For Each Cell In Range("AJ5:AJ45")
If Cell = "X" Then
Range("AK5:AK40") = "W"
End If
CurrentRace = .Range("A1").Value
End With
Application.EnableEvents = True
End If
End Sub
OK there are errors within my changes but basically what I'm trying to acheive is after the the first main section of 'ClearContents' I want to refer to AJ5:AJ45, where if there's an"X" in any one of those cells I want the Macro to put a "W" into the adjacent AK cell. (The 'AJ' col. will be referring to the odds in the "F" column). I had actually acheived this earlier using a 'SelectCase' set up but I couldn't integrate into your code , (my lack of knowledge). The above macro won't work at the moment because I'm getting a 'CompileError' "End With Without With".?
The other problem that I still seem to be getting is when testing it in it's unchanged set up is it only appears to fully function after restarting the PC, it will continue to work but if I make any changes I have to shut the system down to retest it even if I put the macro back to it original state. I'm not sure how to test run a Private_Sub macro.
I realise there may be other errors in the changes I've made like will a 'W' go into individual cells or fill the complete range..?? .
I have pasted below the macro that I did build , (it kind of evolved) but it essentially worked but needed 'change events' for it to fire. The auto mouse clicker worked but is a pain in the proverbial, as you can't use the PC unless you stop it. Don't read too much into it as it was one I was messing around with to test it, although the 'SelectCase' part is pretty well correct. The -10 bit was referring to the countown timer to act the same as 'ClearContents' ie it simply changed the 'letter' and it all worked.
Sub auto_openG()
' Run the macro DidCellsChange any time a entry is made in a
' cell in WinMkt-3BACK (3).
ThisWorkbook.Worksheets("WinMkt-3BACK (4)").OnEntry = "DidCellsChangeJJ"
End Sub
Sub DidCellsChangeJJ()
' If time is -10 enter "O"
For Each Cell In Range("AK5:AK10")
If Cell = "W" Then
Call KeyCellsChangedO
End If
If Cell = "O" Then
Call KeyCellsChangedO
End If
Next Cell
End Sub
Sub KeyCellsChangedO()
' Macro2 Macro
For Each Cell In Range("AL5")
If Cell = "NO" Then
Range("AK5:AK10") = "O"
End If
If Cell = "YES" Then
Call KeyCellsChangedJ
End If
Next Cell
End Sub
Sub KeyCellsChangedJ()
' Dim Cell As Object
' If the values in AI5:AI45 are less than 2.6...
For Each Cell In Range("AJ5:AJ10")
If Cell = "X" Then
Call TheSelectCase11
Call TheSelectCase12
Call TheSelectCase13
Call TheSelectCase14
Call TheSelectCase15
Call TheSelectCase16
End If
Next Cell
End Sub
Sub TheSelectCase11()
Select Case Range("AJ5").Value
Case "X"
Range("AK5").Value = "W"
End Select
End Sub
Sub TheSelectCase12()
Select Case Range("AJ6").Value
Case "X"
Range("AK6").Value = "W"
End Select
End Sub
Sub TheSelectCase13()
Select Case Range("AJ7").Value
Case "X"
Range("AK7").Value = "W"
End Select
End Sub
Sub TheSelectCase14()
Select Case Range("AJ8").Value
Case "X"
Range("AK8").Value = "W"
End Select
End Sub
Sub TheSelectCase15()
Select Case Range("AJ9").Value
Case "X"
Range("AK9").Value = "W"
End Select
End Sub
Sub TheSelectCase16()
Select Case Range("AJ10").Value
Case "X"
Range("AK10").Value = "W"
End Select
End Sub
Well thats it in more than a nutshell, If you or anybody can assist it would be appreciated in the meantime I'll keep bashing away.
Thanks Peter
