Hi all
Can anyone tell me why this code doesn't work in Excel 2003?
Can anyone tell me why this code doesn't work in Excel 2003?
Code:
If Not Intersect(Target, Range("A3:D1002")) Is Nothing Then
ActiveSheet.Unprotect
Application.EnableEvents = False
If Len(Range("A" & Target.Row).Value) * Len(Range("B" & Target.Row).Value) * Len(Range("C" & Target.Row).Value) > 0 Or Len(Range("A" & Target.Row).Value) + Len(Range("B" & Target.Row).Value) + Len(Range("C" & Target.Row).Value) + Len(Range("D" & Target.Row).Value) = 0 Then
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add Key:=Range("B3:B1002"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveSheet.Sort.SortFields.Add Key:=Range("A3:A1002"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveSheet.Sort.SortFields.Add Key:=Range("D3:D1002"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveSheet.Sort
.SetRange Range("A3:E1002")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
Application.EnableEvents = True
ActiveSheet.Protect
End If