Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run macro without open an excel sheet

Status
Not open for further replies.

yarondavid

Programmer
May 8, 2006
20
IL
Hi,

I have a VBA macro that run from other excel sheet (I add a 'Custom Button' in the Excel's menu bar).
But when I run the macro from "target" sheet, an excel sheet that contains the macro in ThisWorkbook, is also opened.
How can I automatically close the "source" excel sheet which contain the macro in ThisWorkbook object.

Thanks
 
Just add code to the end of the macro:

ThisWorkbook.Close SaveChanges:=False

If multiple users may use the macro then mark the file Read Only from Windows explorer.

You may also consider making the workbook hidden.

Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top