LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Running macro at startup

Brian

Go to VB Editor with your workbook open. Right Click on This Workbook and
then View Code.

Paste the code in here after Private Sub Workbook_Open() and remove any
reference to Private Sub CommandButton1_Click().

The code will run whenever that workbook is opened.

HTH.

Jim



"Brian McGuire" wrote in message
...
Hi,

I have a macro that sorts through data that I have in a spreadsheet. As it

stands now, the macro is run by pressing a command button. I would like the
sort to occur automatically every time the workbook is opened. I dont want
the macro to run at the startup of every workbook, just the workbook with
the data in it. The code as it stands now is:

Private Sub CommandButton1_Click()
'Module Sorting Macro
'1/17/04

Range("C2").Select
Range("A1:P108").Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=

_
xlGuess, OrderCustom:=1, MatchCase:=False,

Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Where would I have to put this or how do I need to alter the code to make

this sort exceute everytime the workbook opens. Any help is greatly
appreciated. Thanks.

Brian



 
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
Running auto correct on startup? Mitch Excel Discussion (Misc queries) 1 November 28th 05 06:38 PM
Running macro at startup Beto[_3_] Excel Programming 0 January 21st 04 07:24 PM
Running macro at startup Bob Phillips[_6_] Excel Programming 0 January 21st 04 06:29 PM
Run a macro at startup Robyn Thomas Excel Programming 1 January 10th 04 09:44 PM
running macro upon a spreadsheet's startup Joe S. Excel Programming 2 December 16th 03 10:00 PM


All times are GMT +1. The time now is 12:04 PM.

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"