Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 18th, 2011, 04:21 PM
Registered User
 
Join Date: May 2011
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default Sort a column with complex keys

Hello,

I have a spreadsheet with multiple columns that I need to sort, by writing a macro, based on 2 keys.

1) Name
2) Date and Time(occupies one cell in the spreadsheet)

I have sorted based on name, but I am having difficulty sorting the date based on date and time, as Excel does not recognize the "date and time" column as pertaining to a particular format.

An example would be:

Date and Time of Events | Events
01-SEP-2007 01:46:15 AM | Event3
01-SEP-2007 12:46:08 PM | Event4
01-NOV-2006 12:19:10 PM | Event2
01-SEP-2007 01:46:18 PM | Event5
02-AUG-2004 03:46:01 PM | Event1


How do I get the data sorted chronologically?

Kindly help.
 
Old May 21st, 2011, 03:02 PM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 171
Thanks: 0
Thanked 14 Times in 14 Posts
Default

Try recording a macro where you sort the data manually, then modify that according to your needs.

I've had the same problem, if I recall, Excel doesn't store a DateTime internally as such, instead it stores it as a number. Try using a Double variable to hold the Date/Time if you're writing some sorting algorithm, though not sure why you wouldn't just use Excel's built-in sorting capabilities.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How To sort Gridview Column bt Time Only rao965 ASP.NET 2.0 Professional 0 May 22nd, 2009 04:30 AM
VBA Column Sort Order and numbers Jack1000 BOOK: Access 2003 VBA Programmer's Reference 1 October 5th, 2006 10:53 PM
To sort a hashmap using its keys and/or values Mr. Ram Java Basics 1 June 1st, 2006 11:19 PM
How to sort a column in data grid: kenn_rosie ASP.NET 1.0 and 1.1 Basics 1 January 26th, 2006 02:03 PM
Sum a column from complex recordset shogg Access ASP 1 May 5th, 2005 07:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.