So I have an excel file, with some VBA code in it. The problematic bit is that I need to sort a lot of data by barcode number first, then by Date of visit (each barcode visits multiple times).
This all works fine with random test data that I generated. It gets all sorted by barcode, then by date from latest to earliest.Great!
But not, when I try to use actual data, it doesn't: the barcode gets sorted all right but not the date. The actual data will come from an Android app (Xscan) that has CSV files as output.
Unfortunately, the data exports looks like this "21/10/2014". When I try to have it sorted, it only sorts it according to the very first number, not as a date (not very useful)... so no matter what the month is, if the day is 31 st, it'll be place highest.
I have tried the following: changing datatype back & forth, and run the code with datatype set to different things, but it still doesn't work.
****How can I make Excel understand that 21/10/2014 is to be read as a date, even though it comes from a CSV file and looks like a string/weird division?****
Ideally, the solution could be coded into VBA somehow... I'm dealing with very low-tech skills users....
EDIT: See screenshot below: the column I need to sort by is column H. It doesn't matter if I set data type to Number, date, general.... Still does the same. As for the code:
Function sorting_all(mySheet As Worksheet, myRangeRow As Range, myRangeCol As Range, secondSort As String)
Dim myCol As Range
Set myCol = getCol(mySheet, secondSort)
mySheet.Range("A1", mySheet.Cells(myRangeRow.Row, myRangeCol.Column)).Sort key1:=mySheet.Range("A1"), order1:=xlAscending, key2:=mySheet.Range(Columns(myCol.Column).Address()), order2:=xlDescending, Header:=xlYes, Orientation:=xlSortColumns
End Function
The barcode is in column A and always will be, hence the hardcode (I know I know). That's the key1. Key2 is the date of visit (though the function is called to sort other things, hence the secondsort variabel).

Further EDIT: So apparently the output file from the application isn't really saved as a .CSV (even though that's what the app claims), it is saved as a Excel 97-2003 file. If I copy-past from that file, it doesn't work. If I saved the file as a CSV (properly), THEN copy-past from it.... it works. Not gonna lie, I hate Excel. Not built-in function to change this from the app. So the heart of the matter might be between the Excel 97-2003 file format & my Excel 2010 file that I use... In any case it does seem that importing the data through VBA will be the best answer.