Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to run VBA macro when the workbook is open?

Hi
I write a Macro in VBA IDE module 1 as:

sub Selection()
xxxxxxx
end sub

If I want EXCEL to run it when this workbook is open,how
can I do that by VBA for that ?(Any sample code available?)


Thanks!

BRs
Ji
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default How to run VBA macro when the workbook is open?

Hi:

Put the following macro in the ThisWorkbook code module:

Private Sub Workbook_Open()
Call Selection
End Sub

I would suggest calling the macro something other than "Selection", though.
Never use reserved words as names!

Regards,

Vasant.




"Ji Wenke" wrote in message
...
Hi
I write a Macro in VBA IDE module 1 as:

sub Selection()
xxxxxxx
end sub

If I want EXCEL to run it when this workbook is open,how
can I do that by VBA for that ?(Any sample code available?)


Thanks!

BRs
Ji



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 in 2nd Open workbook Steve Excel Discussion (Misc queries) 1 January 28th 08 05:35 PM
Open Workbook Macro??? Supe Excel Discussion (Misc queries) 2 December 19th 07 08:37 PM
Run a macro when I open a workbook CraigJ Excel Discussion (Misc queries) 1 June 13th 07 04:04 PM
How to Run Macro in open workbook/s hni Excel Discussion (Misc queries) 1 October 31st 05 10:14 AM
run macro on workbook open kevin Excel Discussion (Misc queries) 3 March 4th 05 10:12 AM


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