wrecclesham
Board Regular
- Joined
- Jul 24, 2019
- Messages
- 52
- Office Version
- 365
- Platform
- Windows
I use the following VBA code to sort a list of dates in ascending order.
The problem is that in some cells in the date column, the value is a word rather than a date, and those rows must be sorted above all of the dates. Right now, the cells with text values are moved to the bottom of the list.
Does anyone know how I can modify my existing code to change the sort order slightly, so that any text strings appear at the top of my list, instead of at the bottom?
The dates must still be in ascending order, so I can't solve this by simply switching the sort order to "descending".
Code:
Range("A1:B10").Sort Key1:=Range("A1"), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
The problem is that in some cells in the date column, the value is a word rather than a date, and those rows must be sorted above all of the dates. Right now, the cells with text values are moved to the bottom of the list.
Does anyone know how I can modify my existing code to change the sort order slightly, so that any text strings appear at the top of my list, instead of at the bottom?
The dates must still be in ascending order, so I can't solve this by simply switching the sort order to "descending".