View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Run macro in one open workbook only

Paul,

You could put all that code in the BeforeClose event of your one workbook,
remove it from elsewhere.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Paul S" wrote in message
ups.com...
Thanks Bob,

I should have posted my macro as well, it also contains a save, so I'm
not sure if this way will work, all my sheets except one need to be
hidden in any saved file (one way to secure it a little better)

Here is my macro

Sub MySave()

Application.ScreenUpdating = False

ReturnSheet = ActiveSheet.Name
ReturnAddress = ActiveCell.Address

'hide all the sheets except one
For i = 2 To Sheets.Count
Sheets(i).Visible = xlVeryHidden
Next i

ActiveWorkbook.Save

'unhide all the sheets again
Show_all

Sheets(ReturnSheet).Select
Range(ReturnAddress).Select

End Sub