View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Hard code the workbook name in macro

Hi,

Try this with the name changed to your other workbook

Workbooks("Otherbook.xls").Sheets("Sheet2").Delete

Mike

"Bruce" wrote:

I have a macro to delete a worksheet.
When its run multiple excel files are open. To be sure it doens't accidently
delete the sheet from the wrong file, how can I hardcode the workbook name
into my macro. Assume my workbook is called myFile.xls

Bruce

Sub DelSheets()
Sheets("Sheet2").Delete
End Sub