![]() |
automatically sorting
does anyone know how to automatically sort in excel? if one column changes
how to link the entire rows together to automatically sort when the numbers change? Thanks! |
automatically sorting
Hi Viki
If you put the code below into the worksheet module you wish to sort automatically it should work for you, though it will use a sort key of the column a you can change this easily enough by recording a macro while you do the sort of sort you require. Option Explicit Dim LastRow As Integer Dim LastCol As String Dim MyCell As String Private Sub Worksheet_Change(ByVal Target As Range) LastRow = [A65535].End(xlUp).Row LastCol = [A1].End(xlToRight).Address If Len(LastCol) = 4 Then MyCell = Mid(LastCol, 2, 1) & LastRow Else MyCell = Mid(LastCol, 2, 2) & LastRow End If Range("A1", MyCell).Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _ xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End Sub Hope this helps Steve |
All times are GMT +1. The time now is 12:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com