By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,334 Members | 2,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,334 IT Pros & Developers. It's quick & easy.

How to Get Excel 2007 "Sort By" ??

P: 7

Is there a way to get Excel 2007 "sort by" value from a cell range??

to be more clear, if column header is country and you sorted cell range (A1,A10) by country, is there a way to get "country" using C#???

Jan 18 '09 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 807
It is frustrating that the sort dialog, xlDialogSort, knows this information, but mere mortals do not have access to it. There are three ugly ways that I can think of:
(1) briefly show the dialog and use API calls to retrieve the text from the dialog, but speaking from experience, you will get gray hairs doing this and the users will wonder what flashed up on the screen.
(2) examine the columns of data in code and determine which one is sorted, but if the data is already sorted, this will not get the users last sort operation.
(3) if you are only doing the sort in code, keep track of it yourself. You can even stash this information in a custom doc property, so you can retrieve it when opening a workbook.
Jan 19 '09 #2

P: 7
SammyB , thank you for your answer, i posted this question on many forums, all started guessing, this the only answer i needed, thank you very very much for your help.

According to the method i followed earlier,the way is to examine the data itself by getting the sort address from user last sort operation, i think this workaround did it for me but i thought there is an easier way to do it, i hate microsoft for not supporting this property.

thank you again, appreciated.
Jan 20 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.