Thread: Sheet to close
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Robert Flanagan Robert Flanagan is offline
external usenet poster
 
Posts: 71
Default Sheet to close

You are comparing a worksheet object to a text value. Do this instead:

If wsShtToSave.Name = "Master" Then

Robert Flanagan
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel


"oldjay" wrote in message
...
Why won't this work?

oldjayo

Sub test()

Dim wsShtToSave As Worksheet
Set wsShtToSave = ActiveSheet
If wsShtToSave= "Master" Then
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
End Sub