Code to Sort a Range in Excel - can use in Access |
Post Reply |
Author | ||
Crystal Long
Microsoft MVP Joined: 21 May 2012 Location: Colorado Status: Offline Points: 35 |
Post Options
Thanks(0)
Posted: 04 Jul 2012 at 6:52pm |
|
Code to Sort a Range in Excel code to sort a range in Excel by columns or rows. Specify worksheet, row numbers, and column letters for easy calling from code. This code can be called by Access too!
Here is a routine I wrote to test it. You can modify this to test it in your application:
here is a good Help page on MSDN: Range.Sort Method (Excel)http://msdn.microsoft.com/en-us/library/ff840646.aspxsyntax: Range.Sort(Key1, Order1, Key2, Type, Order2, Key3, Order3, Header, OrderCustom, MatchCase, Orientation, SortMethod, DataOption1, DataOption2, DataOption3) I found better explanations of the parameters here: Range.Sort MethodNamespace: Microsoft.Office.Interop.ExcelAssembly: Microsoft.Office.Interop.Excel (in microsoft.office.interop.excel.dll) http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.sort%28v=office.11%29.aspx#Y602 the Worksheet object Sort does not work for just a range Feedback is appreciated, thank you Warm Regards, Crystal Microsoft MVP remote programming and training Access Basics by Crystal http://www.AccessMVP.com/strive4peace Free 100-page book that covers essentials in Access http://www.YouTube.com/LearnAccessByCrystal * (: have an awesome day :) * |
||
Warm Regards,
Crystal Microsoft MVP Remote Training & Programming Let's Connect and Build Together http://www.AccessMVP.com/strive4peace http://YouTube.com/LearnAccessByCrystal ~have an awesome day ~ |
||
Sponsored Links | Want a good read? Try The Summer of His Life (available on Amazon!) |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |