exclusive macros

  • Thread starter Thread starter Fan924
  • Start date Start date
F

Fan924

Can a macro be made so that it will only work in the workbook it
belongs to?
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top