MFish
Board Regular
- Joined
- May 9, 2019
- Messages
- 76
Hi there,
I'm trying to sort my table off of this code and it works great with letters to sort alphabetically, but numerically... It sucks.
It will easily sort out, A to AA to BA to CF, etc. No problem. But, with numbers it doesn't. I have values like 1-1, 1-2, 2-1, 11-1 and it will sort 1-1, 1-2, 11-1, 2-1. I've tried to add a space between the numbers and "-" to see if the sorting will go numerically by 1, 2, 3, etc. but it still sorts it out like A, AA, B, BB format, if that makes sense. How do I get it to sort in order how I want it to?
I'm trying to sort my table off of this code and it works great with letters to sort alphabetically, but numerically... It sucks.
Code:
Sub SortTable()
Range("B40").Select
Set BillsT = Range(ActiveCell, ActiveCell.End(xlDown).Offset(0, 5))
BillsT.Select
Worksheets("Master Data Sheet").Range(Selection, Selection).Sort _
key1:=Worksheets("Master Data Sheet").Range(ActiveCell, ActiveCell)
End Sub
It will easily sort out, A to AA to BA to CF, etc. No problem. But, with numbers it doesn't. I have values like 1-1, 1-2, 2-1, 11-1 and it will sort 1-1, 1-2, 11-1, 2-1. I've tried to add a space between the numbers and "-" to see if the sorting will go numerically by 1, 2, 3, etc. but it still sorts it out like A, AA, B, BB format, if that makes sense. How do I get it to sort in order how I want it to?