-
Column Sorting
I recorded a macro so that I could hopefully learn how to code it, but I'm having problems.
ActiveCell.Cells.Select
Selection.Sort Key1:=ActiveCell.Offset(0, 2).Range("A2"), Order1:= _
xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers
What am I doing wrong below?
ActiveCell.CurrentRegion.Select
Range("CurrentRegion").Sort Key1:=Range("C1")
-
CurrentRegion is a VBA range, you are trying to use it as an Excel defined name.
Try
[vba]
ActiveCell.CurrentRegion.Select
Selection.Sort Key1:=Range("C1")
[/vba]
or better still
[vba]
ActiveCell.CurrentRegion.Sort Key1:=Range("C1")
[/vba]
-