Totally Totally baffled
Maybe you intended to post all the code but clearly you didn't.
Your code includes
If ActiveCell.Row < 10 Then
populate the variables rowtop etc
But if ActiveCell.Row = 10 then
the variables are not populated so obviously the code will fail, at least it
would on the basis of the sample of code you posted.
However, we have no way of knowing if maybe you had already populated the
variables because you have not shown us your code, or maybe some other
problem.
Regards,
Peter T
"ordnance1" wrote in message
...
That is all the code.
And it is ActiveCell.Row 10 , not ActiveCell.Row = 10 and that does
work.
"Peter T" <peter_t@discussions wrote in message
...
Impossible to say without knowing anything about the code that precedes
what you have shown us.
FWIW looking at the snippet you did show us, if ActiveCell.Row = 10 your
code wouldn't work.
Regards,
Peter T
"ordnance1" wrote in message
...
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
|