LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to close a workbook which contains the macro that's just been run?


Hello~

I would like to be able to include a section of code in my macro to b
able to close the workbook in which the macro resides

I've tried the below section of code (in red):

Sub ReplaceNames()
<MY CODE
. . .

'Select a workbook to make active
Workbooks("Replace_All Names.xls").Activate
'Close active workbook
ActiveWorkbook.Close

End Sub

Note: the workbook which contains this macro is called "Replace_Al
Names.xls"

but this brings up the followng error message window:
"Microsoft Excel cannot find matching data to replace. No cell in th
selection contains what you typed, or no records match the criteria"

Are there any other alternatives??

:

--
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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Close a specific workbook. Dmad11 Excel Discussion (Misc queries) 1 July 7th 09 09:28 PM
Macro to close workbook with prompt JMac[_2_] Excel Worksheet Functions 1 January 31st 08 05:29 PM
Macro to close workbook and re-open new copy Dave Lagergren Excel Discussion (Misc queries) 2 February 28th 07 10:11 PM
run macro on workbook close Nigel Excel Discussion (Misc queries) 3 November 29th 05 08:48 PM
Close Workbook from Macro Lou Excel Programming 2 May 18th 04 02:26 AM


All times are GMT +1. The time now is 11:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"