Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default exclusive macros

Can a macro be made so that it will only work in the workbook it
belongs to?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default exclusive macros



You Could Try somthing like...

Function IsWorkbook() As Boolean
IsWorkbook = ActiveWorkbook.Name = ("Book2")
End Function

Sub Test()
If IsWorkbook = True Then
MsgBox "Your Macro Here"
Else
MsgBox "Sorry no Macro for you"
End If
End Sub



"Fan924" wrote:

Can a macro be made so that it will only work in the workbook it
belongs to?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default exclusive macros

Thanks, I will try this.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default exclusive macros


Depends on what your macro does, you can refer to objects in the
workbook by using ThisWorkBook, e.g.

Code:
--------------------

With ThisWorkbook
.Sheets(1).UsedRange.Copy .Sheets(2)
End With
--------------------


Or


Code:
--------------------
If Not ActiveWorkbook.Name = ThisWorkbook.Name Then Exit Sub
'your code here
--------------------


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=38704

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default exclusive macros

Function IsWorkbook() As Boolean
IsWorkbook = ActiveWorkbook.Name = ("Book2")
End Function

Sub Test()
If IsWorkbook = True Then
MsgBox "Your Macro Here"
Else
MsgBox "Sorry no Macro for you"
End If
End Sub


I could not get this to work, Thanks to Chip Pearson's timely post, I
made a few changes to it and it worked.

If ThisWorkbook.FullName = ActiveWorkbook.FullName Then
MsgBox "Your Macro Here"
Else
MsgBox "Sorry no Macro for you"
End If
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
File in Exclusive Use SSi308 Excel Discussion (Misc queries) 3 June 3rd 10 08:59 PM
make two range exclusive clara Excel Programming 1 May 2nd 07 09:12 PM
2 IF Statements not mutually exclusive Bev Excel Discussion (Misc queries) 2 August 24th 06 05:23 AM
Exclusive OR question Frederick Chow Excel Programming 8 August 15th 06 12:51 AM
Exclusive use Problem TC Excel Discussion (Misc queries) 0 July 12th 05 06:09 PM


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