Thread: CLOSE WB
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
MBSNewbie MBSNewbie is offline
external usenet poster
 
Posts: 7
Default CLOSE WB

If you are copying a worksheet to a new workbook, try moving it instead. I
have a macro that grabs several worksheets from various sources and moves
them to a new workbook. When the worksheet is moved, it automatically closes
the original workbook. (It's the only worksheet in the original)

ChDir "\\ma-sql\erp7\FRx\IODATA\OPxRAW"
Workbooks.Open Filename:="\\ma-sql\erp7\FRx\IODATA\OPxRAW\COO.xls"
Sheets("COO").Select
Sheets("COO").Move Befo=Workbooks("FormatOPx.xls").Sheets(1)

** You would replace anything in quotes with your data **

"Ronbo" wrote in message
...
No virus, just a macro that will clean-up numerous open workbooks that
have
been used in creating a master wb and are no longer needed and do not need
to
be saved. This saves the time of going into each and shutting them down.
And it is only used on my computer.

I saw code on "close all but active", but I need the active and "workbook
2" to remain open.

"NickH" wrote:

Ronbo,

Are you trying to write a macro virus???

That kind action from your code would be potentially harmful to
people's data and make you a very unpopular bunny.

NickH