Sub Test()
Dim SortLastRow As Long
Dim SortLastColumn As Long
Range("A1").Select
On Error Resume Next
SortLastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
SortLastColumn = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column
SortLastCell = Cells(SortLastRow, SortLastColumn).Address
SortRange = "A1:" & SortLastCell
Range(SortRange).Select
intSortRC = Selection.Rows.Count
Range("A1").Select
Cells.Find("Network #", ActiveCell, xlValues, xlWhole, xlByColumns, xlNext, False, False).Select
Selection.Resize(intSortRC, 1).Select
Selection.Name = "SortNetworkRange"
Range("A1").Select
Cells.Find("Position #", ActiveCell, xlValues, xlWhole, xlByColumns, xlNext, False, False).Select
Selection.Resize(intSortRC, 1).Select
Selection.Name = "SortPositionRange"
Range("A1").Select
Cells.Find("Room", ActiveCell, xlValues, xlWhole, xlByColumns, xlNext, False, False).Select
Selection.Resize(intSortRC, 1).Select
Selection.Name = "SortRoomRange"
Range(SortRange).Activate
ActiveWorkbook.Worksheets("Full").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Full").Sort.SortFields.Add Key:=Range(SortNetworkRange), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Full").Sort.SortFields.Add Key:=Range(SortPositionRange), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Full").Sort.SortFields.Add Key:=Range(SortRoomRange), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Full").Sort
.SetRange Range(SortRange)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
End Sub
Anyone see what i have wrong in this code? I crafted it off of the record macro stuff so i might have it... wrong.
Bookmarks