Hello everyone, I have a lit of parts with part numbers in row b. Some numbers are only numeric and some part numbers start with "a-" (ex. 23443555, 3465787 ,A-10123 ,A-202454, etc.). I need to sort them by ascending order but have the parts starting with "a" on the top of the list. I can get them to sort to ascending order but the "a-" part numbers end up on the bottom of the list. Is there a way to fix this using the .sort method or will I need to acomplish this with an alternate method? Thanks for the help!
lastRow = Fabsheet.Cells(Fabsheet.Rows.Count, 2).End(xlUp).row
With Fabsheet.Sort
.SortFields.Clear
.SortFields.Add2 Key:=Fabsheet.Range("B6:B" & lastRow), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:="A-", DataOption:=xlSortNormal
.SetRange Fabsheet.Range("A6:P" & lastRow) ' Assuming your data starts from A6 and goes to column P
.Header = xlYes ' If your data has headers
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
lastRow = Fabsheet.Cells(Fabsheet.Rows.Count, 2).End(xlUp).row
With Fabsheet.Sort
.SortFields.Clear
.SortFields.Add2 Key:=Fabsheet.Range("B6:B" & lastRow), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:="A-", DataOption:=xlSortNormal
.SetRange Fabsheet.Range("A6:P" & lastRow) ' Assuming your data starts from A6 and goes to column P
.Header = xlYes ' If your data has headers
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With