If all the cells in column AB have numerical values (none are empty), you can remove 0(zero) from these cells before sorting, then sort the range and finally restore zeros in the empty cells. Review the following example:
Sub Makro1()
Range("B2:B9").Replace What:="0", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
With ActiveSheet.Sort
.SortFields.Clear
.SortFields.Add2 Key:=Range("B2:B9"), _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal
.SetRange Range("A1:B9")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("B2:B9").Replace What:="", Replacement:="0", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
End Sub
Artik
Bookmarks