Disable Events

  • Thread starter Thread starter wiwi
  • Start date Start date
W

wiwi

I have a workbook ("Marketing.xls") and contain a macro as below. When I
save as the file to another name, I want to disable the macro. Please
help ... my macro won't work


Private Sub Workbook_Open()

If ThisWorkbook.Name = "Marketing.XLS" Then
For Each ws In Worksheets
If ws.Name Like "Costing (2)" Or ws.Name Like "T&A (2)" Or
ws.Name Like "Order Confirmations (2)" Then
ws.Delete
End If
Next ws
End If
End Sub
 
Could it be as simple as an uppercase/lowercase problem:

Maybe:
If ThisWorkbook.Name = "Marketing.XLS" Then
should be:
If lcase(ThisWorkbook.Name) = lcase("Marketing.XLS") Then


I'm not sure if "my macro won't work" means that it runs when it shouldn't or it
never runs at all???
 
I suspect it is the case of the filename versus the test you are using.

Try changing the 2nd line to read

If UCase(ThisWorkbook.Name) = "MARKETING.XLS" Then

Cheers
N
 
Back
Top