Prev: Change a default Excel warning
Next: #Value! cell
From: kc9r0n on 12 Mar 2010 10:11 I have the following code in my worksheet: Private Sub Worksheet_SelectionChange(ByVal Target As Range) ' Watching for changes in cells {H,L,O,T}{2,5,8,...} If (Target.Cells.Count = 1 And _ Target.Row Mod 3 = 2 And _ Target.Column Mod 4 = 0 And _ Target.Column >= 8 And _ Target.Column <= 20) Then If (Target.Value > 0) Then On Error GoTo ErrHandler Application.EnableEvents = False Call CheckDosage(Target) ErrHandler: Application.EnableEvents = True On Error GoTo 0 End If End If End Sub I have the following problems and wondering is behavior is expected: 1) If I click on or enter one of these cells(arrow keys), my sub routine is called. (Cell not changed, just visited) 2) if I enter data into one of these cells and if I use an arrow key, tab key, or enter (and have "Move selection after Enter"), the sub routine is not called. Do I need to somehow use Application.OnKey to "see" the changed cell b4 we physically move from it?
From: kc9r0n on 12 Mar 2010 10:23 "kc9r0n" wrote: > I have the following code in my worksheet: > > Private Sub Worksheet_SelectionChange(ByVal Target As Range) > ' Watching for changes in cells {H,L,O,T}{2,5,8,...} > If (Target.Cells.Count = 1 And _ > Target.Row Mod 3 = 2 And _ > Target.Column Mod 4 = 0 And _ > Target.Column >= 8 And _ > Target.Column <= 20) Then > If (Target.Value > 0) Then > On Error GoTo ErrHandler > Application.EnableEvents = False > Call CheckDosage(Target) > > ErrHandler: > Application.EnableEvents = True > On Error GoTo 0 > End If > End If > End Sub > > I have the following problems and wondering is behavior is expected: > 1) If I click on or enter one of these cells(arrow keys), my sub routine is > called. (Cell not changed, just visited) > 2) if I enter data into one of these cells and if I use an arrow key, tab > key, or enter (and have "Move selection after Enter"), the sub routine is > not called. > > Do I need to somehow use Application.OnKey to "see" the changed cell b4 we > physically move from it? nevermind I am using selectionchange not chang! duh
|
Pages: 1 Prev: Change a default Excel warning Next: #Value! cell |