Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10
Default Sorting Macro in Excel 2007

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Sorting Macro in Excel 2007

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Excel 2007 Macro Question vtec Excel Discussion (Misc queries) 4 April 19th 07 02:14 PM
Sorting by color Excel 2007 CathyZ Excel Discussion (Misc queries) 1 March 28th 07 01:12 AM
sorting on imported Data Excel 2007 Dan Shallbetter Excel Discussion (Misc queries) 3 February 19th 07 03:10 PM
Writing new macro in Excel 2007 Christopher Excel Discussion (Misc queries) 2 December 22nd 06 07:41 AM


All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"