O
OrientalPearl
Hello,
Basically I want the following to happen:
Whenever a user changes some value(kinda focus change?), macro will
check for the validality of the entry. In case of an invalid one, it
clears the bad content and fires an alert, waiting for a new input from
the user.
here's the code I use:
==========================================
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit
'Find the "blank Row"
Dim textRow As Integer
textRow = Range("Blank_row").Row - 1
Application.EnableEvents = False
''check for invalid Pool nomination entries
If (Target.Column = 3 Or Target.Column = 9) And Target.Row > 25 And
Target.Row <= textRow And Target.Value = "Pool" And Range("F10").Value
<> "Pooling" Then GoTo wrongPoolEntry
wrongPoolEntry:
MsgBox "Invalid entry. Select 'Pooling' as Transaction Type to
proceed.", vbExclamation
Target.ClearContents
Target.Select
Exit Sub
End Sub
==================================
Mainly two undesirable phenomena:
1. Whatever changes to the existing value regardless of valid or
invalid ones, the alert is fired. This should not happen as this should
only if the new value is "Pool" which is taken as invalid whilst the
other cell(F10) is not "Pooling"
2. The alert is undismissible. It comes back immediately everytime when
the OK button is clicked. So nothing else can be done.
What causes the abnormity? Any solution ideas?
Thanks in advance and regards
Frank
Basically I want the following to happen:
Whenever a user changes some value(kinda focus change?), macro will
check for the validality of the entry. In case of an invalid one, it
clears the bad content and fires an alert, waiting for a new input from
the user.
here's the code I use:
==========================================
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit
'Find the "blank Row"
Dim textRow As Integer
textRow = Range("Blank_row").Row - 1
Application.EnableEvents = False
''check for invalid Pool nomination entries
If (Target.Column = 3 Or Target.Column = 9) And Target.Row > 25 And
Target.Row <= textRow And Target.Value = "Pool" And Range("F10").Value
<> "Pooling" Then GoTo wrongPoolEntry
wrongPoolEntry:
MsgBox "Invalid entry. Select 'Pooling' as Transaction Type to
proceed.", vbExclamation
Target.ClearContents
Target.Select
Exit Sub
End Sub
==================================
Mainly two undesirable phenomena:
1. Whatever changes to the existing value regardless of valid or
invalid ones, the alert is fired. This should not happen as this should
only if the new value is "Pool" which is taken as invalid whilst the
other cell(F10) is not "Pooling"
2. The alert is undismissible. It comes back immediately everytime when
the OK button is clicked. So nothing else can be done.
What causes the abnormity? Any solution ideas?
Thanks in advance and regards
Frank