Hi guys, fairly simple one, yet it has me stumped.
Trying to change my code to add another automatic function in my document. Here is the snippet of code involved:
'Automatic Date Update/Sheet ordering
Sub Worksheet_Change(ByVal Target As Range)
Dim updatedDate As Date, rngETA As Range, rngStatus As Range, rngNotes As Range, LRow As Long
'Today's date
updatedDate = Now()
'Find last row and set ranges
LRow = Cells(Rows.Count, 1).End(xlUp).Offset(0, 0).Row
Set rngETA = Range("J2:" & "J" & LRow)
Set rngStatus = Range("L2:" & "L" & LRow)
Set rngNotes = Range("M2:" & "M" & LRow)
'Auto date update - on ETA change
If Not Intersect(Target, rngETA) Is Nothing Then
If Target.Count > 1 Then Exit Sub
Target.Offset(, 1).Value = updatedDate
End If
'Auto date update - on status change
If Not Intersect(Target, rngStatus) Is Nothing Then
If Target.Count > 1 Then Exit Sub
Target.Offset(, -1).Value = updatedDate
End If
'Auto date update - on note change
If Not Intersect(Target, rngNotes) Is Nothing Then
If Target.Count > 1 Then Exit Sub
Target.Offset(, -2).Value = updatedDate
End If
'Auto sheet odering by status & debtor name
Rows("1:" & LRow).Sort Key1:=Cells(2, 12), Key2:=Cells(2, 1), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End Sub
Essentially what I would like to do is if text is entered into range L2:L* (where * is last row- LRow in my code) to have upper case. I have tried:
'Auto date update - on status change
If Not Intersect(Target, rngStatus) Is Nothing Then
If Target.Count > 1 Then Exit Sub
Target.Value = UCase(Target.Value)
Target.Offset(, -1).Value = updatedDate
End If
However the addition of line
Target.Value = UCase(Target.Value)
seems to send the function into a loop and can only be stopped by ESC.
Please assist me as I really would like to have this function. I know it must be something simple that I am overlooking and your help will be greatly appreciated.
Bookmarks