jstone4880
New Member
- Joined
- Sep 29, 2013
- Messages
- 25
I have two subs that work fine (the first one is from this forum many moons ago!)
Can anyone put them together at all as I understand there can only be one worksheet_change sub.
Also, could another behaviour (Racist behaviour) be added as an OR next to "Sexual harassment"?
I am sadly still at a very basic level with code.
Just for context - this is to track worrying behaviours in a school and a Green Form is for safeguarding concerns.
Can anyone put them together at all as I understand there can only be one worksheet_change sub.
Also, could another behaviour (Racist behaviour) be added as an OR next to "Sexual harassment"?
I am sadly still at a very basic level with code.
Just for context - this is to track worrying behaviours in a school and a Green Form is for safeguarding concerns.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
Dim c As Range
For Each c In Target
If WorksheetFunction.CountIf(Range("A:A"), c) = 1 Then
msg = "This is the first time this name has been entered." & vbCr & vbCr & "Are you sure it has been spelt correctly?" & vbCr & vbCr & "Last name, space, then first name."
MsgBox msg, vbExclamation, "New Name"
End If
Next c
Dim xCell As Range, Rg As Range
On Error Resume Next
Set Rg = Application.Intersect(Target, Range("K:K"))
If Not Rg Is Nothing Then
For Each xCell In Rg
If xCell.Value = "Sexual harassment" Then
MsgBox "For this type of behaviour a Green Form needs to be filled in as well."
Exit Sub
End If
Next
End If
End Sub