ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to close a workbook which contains the macro that's just been run? (https://www.excelbanter.com/excel-programming/314366-how-close-workbook-contains-macro-thats-just-been-run.html)

dead_girl[_2_]

How to close a workbook which contains the macro that's just been run?
 

Hi Ryan,

Thank you kindly for your reply.

That extra bit of code (in red) was added after creating my initia
macro, which was running without error until the extra code was added.

Hence, I believe it is that extra bit of code (in red for closing th
workbook) that is the cause of the error message.

In any case, he way I've done it seems to be a bit cumbersome:

1. I select the workbook which contains the macro and make it th
active workbook
Workbooks("Replace_All Names.xls").Activate


2. Then close the active workbook (ie. the workbook which contains th
macro that I've made the active workbook by step 1.)
ActiveWorkbook.Close


Are there any other elegant ways of doing this simple task

:confused:

--
dead_gir
-----------------------------------------------------------------------
dead_girl's Profile: http://www.excelforum.com/member.php...fo&userid=1559
View this thread: http://www.excelforum.com/showthread.php?threadid=27145



All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com