Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disable Events

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


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Disable Events

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

wiwi wrote:

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

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Disable Events

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

"wiwi" wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/





----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disable Events

You're right. The case sensitive problem

Thanks you very muc

--
Message posted from http://www.ExcelForum.com

Reply
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
Events won't Disable! roadkill Excel Discussion (Misc queries) 2 April 26th 06 04:36 PM
events? [email protected] Excel Discussion (Misc queries) 1 September 14th 05 03:26 PM
events Mark[_17_] Excel Programming 1 October 31st 03 09:18 AM
events Mark[_17_] Excel Programming 1 October 29th 03 12:56 PM
Disable Key Events Seth[_3_] Excel Programming 1 October 6th 03 10:28 PM


All times are GMT +1. The time now is 04:50 PM.

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

About Us

"It's about Microsoft Excel"