Autosort multiple columns, Keep records intact.
I'm not able to try this out at the moment, but you would need to add code
that would select the rows that have the same identifying column (I think you
said it was the first) then only sort those rows. This would be done after
you sorted for the 1st column.
--
JNW
"ssGuru" wrote:
I have code that autosorts ONE lookup column whenever a value is
entered.
What change would allow autosorting 3 columns of records but keep
everything ordered by the 1st column and not loose syncing of the
records?
This code perfectly sorts any values placed in col 13 OR 16 of some
lookup lists.
Private Sub Worksheet_Change(ByVal Target As Range)
'DD Define columns to autosort when record added or deleted
If Target.Column = 13 Or Target.Column = 16 Then
Columns(Target.Column).Sort _
Key1:=Cells(1, Target.Column), Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End If
End Sub
I couldn't find a Class property that delt with the issue of sorting
multiple columns and keeping the records intact so I tried this code
change but it did nothing at all that I could see:
Private Sub Worksheet_Change(ByVal Target As Range)
'DD Define columns to autosort when record added or deleted
If Target.Column = 26 And Target.Column = 27 _
And Target.Column = 28 And Target.Column = 29 Then
Columns(Target.Column).Sort _
Key1:=Cells(1, Target.Column), Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End If
End Sub
Thanks, Dennis
|