Moderator: 2020vision
by London_Calling » Sun Jun 06, 2010 3:55 pm
by osknows » Sun Jun 06, 2010 8:26 pm
by London_Calling » Sun Jun 06, 2010 10:22 pm
by osknows » Sun Jun 06, 2010 10:53 pm
Sub Test1()
Application.Enableevents = False
range("a1").value = 10 'this will not trigger an event
Test2 ' call sub Test2
range("a1").value = 40 'this will trigger a worksheet change event
Application.Enableevents = True
end Sub
'=============
Sub Test2()
Application.Enableevents = False
range("a1").value = 20 'this will not trigger an event
range("a1").value = 30 'this will not trigger an event
Application.Enableevents = True
end Sub
by Royville » Tue Jun 08, 2010 10:58 am
by greenfingers » Tue Jun 08, 2010 12:21 pm
Royville wrote:I put the code into sheet4 Worksheet_Change event sheet and it just would not run.
by greenfingers » Tue Jun 08, 2010 12:29 pm
London_Calling wrote:In the context of Worksheet_Calculate and using Application.EnableEvents = False / True, it's driving me a little bonkers that I can't seem to find a solution to vba returning to the top of the event sheet every time it's asked to write something to that sheet (like "BACK" or "LAY").
I would just like it to continue through the code in a normal, linear fashion.
Am I missing something or are there tips and tricks I'm not aware of because it really is a bit frustrating . . .
Cheers
*breaks a nail*
by osknows » Tue Jun 08, 2010 12:35 pm
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim BAarray() As Variant
Application.EnableEvents = False
With ThisWorkbook.Sheets(1)
'code to do what you need in Sheet 1
BAarray = .Range("a1:e5").Value
End With
With ThisWorkbook.Sheets(4)
'code to do what you need in Sheet 4
.Range(.Range("A65536").End(xlUp).Offset(1, 0), _
.Range("A65536").End(xlUp).Offset(UBound(BAarray, 1), UBound(BAarray, 2) - 1)).Value = BAarray
End With
Application.EnableEvents = True
End Sub
by osknows » Tue Jun 08, 2010 12:57 pm
greenfingers wrote:I may be off the mark, but do you have an error handler? If you didn't and there was an error in your code that writes the text to the sheet, then it would abort the code and return to the top on the next worksheet calculation????
Option Explicit
Dim screenUpdateState, statusBarState, calcState, eventsState, displayPageBreakState As Boolean
Private Sub turn_off_events()
screenUpdateState = Application.ScreenUpdating
statusBarState = Application.DisplayStatusBar
calcState = Application.Calculation
eventsState = Application.EnableEvents
displayPageBreakState = ActiveSheet.DisplayPageBreaks 'note this is a sheet-level setting
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False 'note this is a sheet-level setting
End Sub
Private Sub turn_on_events()
Application.ScreenUpdating = screenUpdateState
Application.DisplayStatusBar = statusBarState
Application.Calculation = calcState
Application.EnableEvents = eventsState
ActiveSheet.DisplayPageBreaks = displayPageBreakState 'note this is a sheet-level setting
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo PROC_ERR
Dim BAarray() As Variant
turn_off_events
With ThisWorkbook.Sheets(1)
'code to do what you need in Sheet 1
BAarray = .Range("a1:e1").Value
End With
With ThisWorkbook.Sheets(4)
'code to do what you need in Sheet 4
.Range(.Range("A65536").End(xlUp).Offset(1, 0), _
.Range("A65536").End(xlUp).Offset(UBound(BAarray, 1), UBound(BAarray, 2) - 1)).Value = BAarray
End With
turn_on_events
Exit Sub
PROC_ERR:
turn_on_events
MsgBox "Error: (" & Err.Number & ") " & Err.Description, vbCritical
End Sub
by osknows » Tue Jun 08, 2010 1:32 pm
by Royville » Tue Jun 08, 2010 3:39 pm
IF timer has incremented THEN
write the data.
END IF
The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.
Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.
Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.
He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.
We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.