AlabasterShelf
New Member
- Joined
- Jun 20, 2014
- Messages
- 5
Hello all,
I have a spreadsheet that is pulling in query data. My VBA code refreshes the query, populates a formulas in two column, and finally sorts the data.
The query refresh is fine. The formula population is fine. The trouble I am having is that the sorting is not behaving. I don't get an error message. And the filter icon has the little triangle that shows excel thinks the column is sorted. But it is not.
In the specific column of interest, I am trying to remove the blank dates and sort oldest to newest. I used the macro recorder to generate the code seen here. I dropped message box indicators in each line of code, and they all worked fine so I know the code is cycling through properly. But it still isn't sorting. As I mentioned, I don't get any kind of error code with this. Anyone have any ideas?
</today(),""late"",""""))"
I have a spreadsheet that is pulling in query data. My VBA code refreshes the query, populates a formulas in two column, and finally sorts the data.
The query refresh is fine. The formula population is fine. The trouble I am having is that the sorting is not behaving. I don't get an error message. And the filter icon has the little triangle that shows excel thinks the column is sorted. But it is not.
In the specific column of interest, I am trying to remove the blank dates and sort oldest to newest. I used the macro recorder to generate the code seen here. I dropped message box indicators in each line of code, and they all worked fine so I know the code is cycling through properly. But it still isn't sorting. As I mentioned, I don't get any kind of error code with this. Anyone have any ideas?
Code:
'sort data
<today(),""late"",""""))"
ActiveWorkbook.Worksheets("OPERATION").ListObjects("OPER").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("OPERATION").ListObjects("OPER").Sort.SortFields.Add _
Key:=Range("OPER[[#All],[WANT_DATE]]"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("OPERATION").ListObjects("OPER").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ThisWorkbook.Worksheets("OPERATION").ListObjects("OPER").Range.AutoFilter Field:=4, Criteria1:="<>"