O
ordnance1
My code below is triggered by a UserForm (when it places data into one of
the cells in rows 5 - 9) to sort names in the cells. It works great the
first and second time it runs but after that it only sorts rows 6 - 9. I am
at a total loss as to how to fix this. Any ideas?
bSELCTIONCHANGE = False
On Error GoTo ErrorHandler
Events.Disable_Events
Application.ScreenUpdating = False
Dim c As Range
Dim rowtop As Integer
Dim row1 As Integer
Dim Row5 As Integer
Set c = ActiveCell
If ActiveCell.Row < 10 Then
rowtop = 4
row1 = 5
Row5 = 9
End If
If Range("E" & rowtop).Value = Range("w1").Value Then
GoTo Continue2
End If
If Range("E" & rowtop).Value > "" Then
Range("D" & row1 & ":E" & Row5).Select
Selection.Sort Key1:=Range("D" & row1), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
Continue2:
c.Select
ErrorHandler:
bSELCTIONCHANGE = True
Application.ScreenUpdating = True
Events.Enable_Events
End Sub
the cells in rows 5 - 9) to sort names in the cells. It works great the
first and second time it runs but after that it only sorts rows 6 - 9. I am
at a total loss as to how to fix this. Any ideas?
bSELCTIONCHANGE = False
On Error GoTo ErrorHandler
Events.Disable_Events
Application.ScreenUpdating = False
Dim c As Range
Dim rowtop As Integer
Dim row1 As Integer
Dim Row5 As Integer
Set c = ActiveCell
If ActiveCell.Row < 10 Then
rowtop = 4
row1 = 5
Row5 = 9
End If
If Range("E" & rowtop).Value = Range("w1").Value Then
GoTo Continue2
End If
If Range("E" & rowtop).Value > "" Then
Range("D" & row1 & ":E" & Row5).Select
Selection.Sort Key1:=Range("D" & row1), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
Continue2:
c.Select
ErrorHandler:
bSELCTIONCHANGE = True
Application.ScreenUpdating = True
Events.Enable_Events
End Sub