deletedalien
Well-known Member
- Joined
- Dec 8, 2008
- Messages
- 505
- Office Version
- 2013
- Platform
- Windows
hi all.
so i have this code, that is supposed to change the text to uppercase if written in lowercase and give an error message if the word "drop" is typed in, BUT this should only apply to column "B" and it gives me an error when i change any other cells (in any other columns)
in addition in want to make just one person in the copmany be able to type DROP in column B <-- is this possible?
anywho here is my code and any help is greatly appreciated
Thanx in advance.
so i have this code, that is supposed to change the text to uppercase if written in lowercase and give an error message if the word "drop" is typed in, BUT this should only apply to column "B" and it gives me an error when i change any other cells (in any other columns)
in addition in want to make just one person in the copmany be able to type DROP in column B <-- is this possible?
anywho here is my code and any help is greatly appreciated
Code:
Private Sub Worksheet_Change(ByVal Target As RANGE)
Application.DisplayAlerts = False
If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
On Error Resume Next
If Not Intersect(Target, RANGE("B:B")) Is Nothing Then
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True
End If
On Error GoTo 0
'Do nothing if more than one cedll is changed or content deleted
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Intersect(Target, RANGE("B:B")) = "DROP" Then
'Stop any possible runtime errors and halting code
On Error Resume Next
'Turn off ALL events so the Target * 2 does not put the code into a loop.
Application.EnableEvents = False
Target = ClearContents
'Turn events back on
Application.EnableEvents = True
'Allow run time errors again
MsgBox "Cannot Select Drop", vbCritical, "Invalid selection"
On Error GoTo 0
End If
End Sub
Thanx in advance.
Last edited: