Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 54
Default Run VBA sort when I open worksheet

I've looked all around this wonderful web and I can't find anything on
executing VBA code when a specific worksheet is opened. There's plenty on
opening the workBOOK but I don't need that. What I'd like to do is have a
sheet automatically sort itself when it's opened.

Sheet name: "Half Payout" or "Sheet2"

sorting code: Range("B3:J99").sort Key1:=Range("D3"), Order1:=xlAscending,
Key2:=Range( _
"F3"), Order2:=xlAscending, Key3:=Range("B3"), Order3:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal

Thanks for any help on this.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Run VBA sort when I open worksheet

Private Sub Worksheet_Activate()
' put your code here
End Sub

Put this in the worksheet code area.
--
Gary''s Student - gsnu200839


"JSnow" wrote:

I've looked all around this wonderful web and I can't find anything on
executing VBA code when a specific worksheet is opened. There's plenty on
opening the workBOOK but I don't need that. What I'd like to do is have a
sheet automatically sort itself when it's opened.

Sheet name: "Half Payout" or "Sheet2"

sorting code: Range("B3:J99").sort Key1:=Range("D3"), Order1:=xlAscending,
Key2:=Range( _
"F3"), Order2:=xlAscending, Key3:=Range("B3"), Order3:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal

Thanks for any help on this.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 54
Default Run VBA sort when I open worksheet

Thanks, GS! I knew it would be something simple like that.

"Gary''s Student" wrote:

Private Sub Worksheet_Activate()
' put your code here
End Sub

Put this in the worksheet code area.
--
Gary''s Student - gsnu200839


"JSnow" wrote:

I've looked all around this wonderful web and I can't find anything on
executing VBA code when a specific worksheet is opened. There's plenty on
opening the workBOOK but I don't need that. What I'd like to do is have a
sheet automatically sort itself when it's opened.

Sheet name: "Half Payout" or "Sheet2"

sorting code: Range("B3:J99").sort Key1:=Range("D3"), Order1:=xlAscending,
Key2:=Range( _
"F3"), Order2:=xlAscending, Key3:=Range("B3"), Order3:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal

Thanks for any help on this.

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
Open File menu sort alphabetical. Celle Excel Discussion (Misc queries) 7 August 20th 08 03:06 PM
How do I get a blank worksheet to open up when I open Excel? Art@ISCO Setting up and Configuration of Excel 0 July 17th 07 01:30 PM
'Save current worksheet'; 'Open next worksheet' - two command buttons englishmustard Excel Discussion (Misc queries) 1 April 7th 06 12:54 PM
Sort order in File Open dialogue box Roberto Excel Discussion (Misc queries) 1 December 12th 05 12:44 AM
How do I get my personal macro worksheet to open whenever I open . Claudia_R Excel Discussion (Misc queries) 3 December 9th 04 11:59 PM


All times are GMT +1. The time now is 09:02 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"