Column Sort

S

Shaz

Hello
I have a table of data.
I would like to sort a column using a macro however the column is
determined by the cell selected. Is this possible.

Shazz
 
N

Nick Hodge

Shazz

If the table is contiguous from cell A1 the code below will work

Sub SortBySelected()
Range("A1").CurrentRegion.Sort Key1:=Range(ActiveCell.Address), _
Order1:=xlAscending, Header:=xlGuess
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
[email protected]
 
Top