Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default Make macro available to all sheets

How do I make my macro run no matter what sheet I'm on in the workbook. I
don't want to put it in my personal.xls. Rather I just want it specific to
this one workbook, but able to run from any sheet. I tried naming it 'Public
Sub Add_New_Person' and placed it in the ThisWorkbook module but it won't run
when I'm in a sheet in the workbook.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,290
Default Make macro available to all sheets


Put the code in a standard module. In the Visual Basic Editor (VBE)...
Insert (menu) | Module
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Bill_S"
wrote in message
How do I make my macro run no matter what sheet I'm on in the workbook. I
don't want to put it in my personal.xls. Rather I just want it specific to
this one workbook, but able to run from any sheet. I tried naming it 'Public
Sub Add_New_Person' and placed it in the ThisWorkbook module but it won't run
when I'm in a sheet in the workbook.
Thanks.
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Make macro available to all sheets

Your code should be in a standard code module (the same place as a recorded
macro ends up). Your public definition should make it accessable for any
sheet. The only issue is that your code needs to reference the active sheet
at all times. Post your code so we can take a look at it...
--
HTH...

Jim Thomlinson


"Bill_S" wrote:

How do I make my macro run no matter what sheet I'm on in the workbook. I
don't want to put it in my personal.xls. Rather I just want it specific to
this one workbook, but able to run from any sheet. I tried naming it 'Public
Sub Add_New_Person' and placed it in the ThisWorkbook module but it won't run
when I'm in a sheet in the workbook.

Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Make macro available to all sheets

Maybe you could modify your macros so that they check where you are before
continuing:


Option Explicit
sub testme()
if activeworkbook.fullname < thisworkbook.fullname then
msgbox "Not available in this workbook!"
exit sub
End if

'real code here
End Sub

ThisWorkbook is the workbook that owns the code. Activeworkbook is the workbook
that's active <bg.




Bill_S wrote:

How do I make my macro run no matter what sheet I'm on in the workbook. I
don't want to put it in my personal.xls. Rather I just want it specific to
this one workbook, but able to run from any sheet. I tried naming it 'Public
Sub Add_New_Person' and placed it in the ThisWorkbook module but it won't run
when I'm in a sheet in the workbook.

Thanks.


--

Dave Peterson
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 to find cell content in sheets and make sheet active Nigel Excel Discussion (Misc queries) 4 June 26th 14 02:38 PM
Macro to Filter Information in Multiple sheets and Make graph misschanda via OfficeKB.com Excel Worksheet Functions 0 August 24th 07 03:25 PM
How do I make changes in all sheets within a workbook? shfz Excel Worksheet Functions 1 August 4th 05 03:17 PM
how do you make macro run across protected sheets ace Excel Discussion (Misc queries) 1 April 13th 05 09:00 AM
i need to make the sheets name come from a cell sam wildig New Users to Excel 8 November 29th 04 02:26 PM


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