Sheet will not execute the sort
Dim PreviousValue
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value <> PreviousValue Then
Sheets("log").Cells(65000, 1).End(xlUp).Offset(1, 0).Value = _
Application.UserName & " changed cell " & Target.Address _
& " from " & PreviousValue & " to " & Target.Value
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PreviousValue = Target.Value
End Sub
Private Sub Worksheet_Change2(ByVal Target As Range)
If Not (Application.Intersect(Worksheets("Sheet1").Range("E:E"), Target) Is Nothing) Then
DoSort
End If
End Sub
Private Sub DoSort()
Worksheets("Sheet1").Range("A:E").sort Key1:=Worksheets("Sheet1").Range("E2"), Order1:=xlAscending, Header:=xlYes
End Sub
- alambert's blog
- Login or register to post comments
- 5191 reads
try this
Private Sub DoSort()
application.enableevents = false
Worksheets("Sheet1").Range("A:E").sort Key1:=Worksheets("Sheet1").Range("E2"), Order1:=xlAscending, Header:=xlYes
application.enableevents = true
End Sub
The log entry works, but not the sort
First part works, second half does not. Any idea what I should do? Is there something I am supposed to do?
Dim PreviousValue
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value <> PreviousValue Then
Sheets("log").Cells(65000, 1).End(xlUp).Offset(1, 0).Value = _
Application.UserName & " changed cell " & Target.Address _
& " from " & PreviousValue & " to " & Target.Value
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PreviousValue = Target.Value
End Sub
SECOND HALF________________________________________________
Private Sub Worksheet_Change2(ByVal Target As Range)
If Not (Application.Intersect(Worksheets("Sheet1").Range("E:E"), Target) Is Nothing) Then
DoSort
End If
End Sub
Private Sub DoSort()
Application.EnableEvents = False
Worksheets("Sheet1").Range("A:E").sort Key1:=Worksheets("Sheet1").Range("E2"), Order1:=xlAscending, Header:=xlYes
Application.EnableEvents = True
End Sub
and
This half works in a stand alone sheet.
Macro order
Is there an order of macro's
what's calling:
what's calling: Worksheet_Change2 ?