Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am having problems sorting Tables in Excel 2007 using C#. The below method
changes the cursor to ascending in the Table's header sort fields but fails to sort the cells. Under debugger the SortField and Table ranges passed to Excel look OK and Apply() executes without errors. Any help will be appreciated. Thanks, Andrew /// <summary /// Sort Table in ascending order by the specified keys /// </summary /// <param name="inTable"input Table to sort</param /// <param name="inColumns"input key column names to use</param public static void SortTableByKeys(Excel.ListObject inTable, string[] inColumns) { inTable.Sort.SortFields.Clear(); foreach (string column in inColumns) { inTable.Sort.SortFields.Add(inTable.ListColumns.ge t_Item(column).Range, Excel.XlSortType.xlSortValues, Excel.XlSortOrder.xlAscending, Type.Missing, Excel.XlSortDataOption.xlSortNormal); } inTable.Sort.SetRange(inTable.Range); inTable.Sort.Orientation = Excel.XlSortOrientation.xlSortColumns; inTable.Sort.MatchCase = false; inTable.Sort.Header = Excel.XlYesNoGuess.xlYes; inTable.Sort.SortMethod = Excel.XlSortMethod.xlPinYin; inTable.Sort.Apply(); } |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
match and sort two different tables | Excel Worksheet Functions | |||
Script to sort tables | Excel Discussion (Misc queries) | |||
Sort two tables of data | Excel Worksheet Functions | |||
sort tables | Excel Worksheet Functions | |||
Automatically Sort Tables | Excel Discussion (Misc queries) |