简体   繁体   中英

how to multi conditionally sort values using vba

So I'm pulling data from an external source which returns Date strings of the given format: "10/26/2013 9:46:46 AM"

When I sort the data it does not seem to be able to distinguish between AM and PM values so many noonish / 1 AM values are moved towards the bottom. Has anyone dealt with this before / have a solution to make it recognize the AM/PM aspect along with the day and time?

Thanks

It looks like it is sorting this as text. It may depend on how the data is getting pulled through. If you select one of the cells and press F2 (to edit) then enter to go to the next cell, does this change your data?

In the code that is pulling the data through, you just need to amend it slightly. Range("D5").value = string

It may change it slightly to maybe 24 hour time depending on your computer settings

我最终使用TimeValue()和DateValue()excel函数对日期和时间进行了分割,然后编写了一个宏,根据代码,日期和时间对3个键进行排序。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM