Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Is there a way to create a sorting macro in Excel 2007 that would allow me to
use it for any workbook and any section of a worksheet? For instance, I would need the macro to work specifically on the rows I highlight only. I would also need to set up the macro to sort based on 2 or 3 column letters (I would just change this in the VBA code for any new workbooks that aren't lined up the same). Thanks for your idea. This would save me so much time. Kevin |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Kevin,
The example below will sort the selected range based on the third column of the selection ascending, and the first column of the selection descending. You can modify it easily; I hope you see the pattern so that you can get it to work in your required situation. HTH, Bernie MS Excel MVP Sub KevinSortMacro() Col1 = 3 Col2 = 1 Selection.Sort Key1:=Selection.Cells(1, Col1), Order1:=xlAscending, _ Key2:=Selection.Cells(1, Col2), Order2:=xlDescending, _ Header:=xlYes End Sub "Kevin K" wrote in message ... Is there a way to create a sorting macro in Excel 2007 that would allow me to use it for any workbook and any section of a worksheet? For instance, I would need the macro to work specifically on the rows I highlight only. I would also need to set up the macro to sort based on 2 or 3 column letters (I would just change this in the VBA code for any new workbooks that aren't lined up the same). Thanks for your idea. This would save me so much time. Kevin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
Excel 2007 Macro Question | Excel Discussion (Misc queries) | |||
Sorting by color Excel 2007 | Excel Discussion (Misc queries) | |||
sorting on imported Data Excel 2007 | Excel Discussion (Misc queries) | |||
Writing new macro in Excel 2007 | Excel Discussion (Misc queries) |