Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
exclusive macros
Can a macro be made so that it will only work in the workbook it
belongs to? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
exclusive macros
Thanks, I will try this.
|
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
File in Exclusive Use | Excel Discussion (Misc queries) | |||
make two range exclusive | Excel Programming | |||
2 IF Statements not mutually exclusive | Excel Discussion (Misc queries) | |||
Exclusive OR question | Excel Programming | |||
Exclusive use Problem | Excel Discussion (Misc queries) |