Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Run sort macro on active worksheet

How can I make the code below work on any worksheet?

Sub SortByDate()

ActiveWorkbook.Worksheets("DateCheck").Sort.SortFi elds.Clear
ActiveWorkbook.Worksheets("DateCheck").Sort.SortFi elds..Add Key:=Range( _
"C4:C24"), SortOn"=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("DateCheck").Sort
.SetRange Range( "B3:K24" )
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Run sort macro on active worksheet

Use ActiveSheet rather than, ActiveWorkbook.Worksheets("DateCheck").
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
Reference active worksheet from macro in personal.xls livetohike Excel Programming 2 May 7th 08 07:25 PM
Need to identify active worksheet in macro MLK Excel Worksheet Functions 1 March 13th 07 04:29 PM
I need to sort an active sheet using the col of the active cell HamFlyer Excel Programming 3 June 6th 06 07:25 PM
How to end macro on inital active worksheet containing macro button that was clicked Silverhawk1 Excel Programming 2 May 14th 04 03:58 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM


All times are GMT +1. The time now is 06:10 AM.

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

About Us

"It's about Microsoft Excel"