ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,756
- Office Version
- 2007
- Platform
- Windows
Morning,
I originally had this code,
I then wanted to include this code by merging the two so the range in question would allow any type content to be changed to uppercase,
I then tried myself & came up with this,
Now i see it change to uppercase & dont receive any errors but that doesnt mean my joined code is correct.
Thanks
I originally had this code,
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
' Exit if more than one cell updated at a time
If Target.Count > 1 Then Exit Sub
' Check to see if value updated is in column B or D
If Target.Column = 2 Or Target.Column = 4 Then
Application.EnableEvents = False
If UCase(Cells(Target.Row, "B")) = "REFUND" Then
Cells(Target.Row, "D") = Abs(Cells(Target.Row, "D")) * -1
Else
If Cells(Target.Row, "B") = "" Then Cells(Target.Row, "D").ClearContents
End If
Application.EnableEvents = True
End If
End Sub
I then wanted to include this code by merging the two so the range in question would allow any type content to be changed to uppercase,
Code:
Private Sub Worksheet_Change(ByVal Target As Range) If Not (Application.Intersect(Target, Range("A5:k28")) _
Is Nothing) Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End With
End If
End Sub
I then tried myself & came up with this,
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
' Exit if more than one cell updated at a time
If Target.Count > 1 Then Exit Sub
' Check to see if value updated is in column B or D
If Target.Column = 2 Or Target.Column = 4 Then
Application.EnableEvents = False
If UCase(Cells(Target.Row, "B")) = "REFUND" Then
Cells(Target.Row, "D") = Abs(Cells(Target.Row, "D")) * -1
Else
If Cells(Target.Row, "B") = "" Then Cells(Target.Row, "D").ClearContents
End If
Application.EnableEvents = True
End If
If Not (Application.Intersect(Target, Range("A5:k28")) _
Is Nothing) Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End With
End If
End Sub
Now i see it change to uppercase & dont receive any errors but that doesnt mean my joined code is correct.
Thanks