ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If Worbook Name = "X" then Prevent Macro From Running (https://www.excelbanter.com/excel-programming/375334-if-worbook-name-%3D-x-then-prevent-macro-running.html)

stevec

If Worbook Name = "X" then Prevent Macro From Running
 
Hi, I have a few macros that need to be run, but only after the user saves
the file as a different name.

Any suggestions that would to add a VBA snippet to a macro that would
prevent it to run if the current workbook name is "X"?

If not too much additional trouble, could I add a pop-up box that states
"Save File as Different Name Before Running Macro." ?

Thanks very much... SteveC

Ron de Bruin

If Worbook Name = "X" then Prevent Macro From Running
 
Hi Steve

Try this

Sub test()
If ThisWorkbook.Name < "X" Then
' your code
Else
MsgBox "Save File as Different Name Before Running Macro"
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"SteveC" wrote in message ...
Hi, I have a few macros that need to be run, but only after the user saves
the file as a different name.

Any suggestions that would to add a VBA snippet to a macro that would
prevent it to run if the current workbook name is "X"?

If not too much additional trouble, could I add a pop-up box that states
"Save File as Different Name Before Running Macro." ?

Thanks very much... SteveC




stevec

If Worbook Name = "X" then Prevent Macro From Running
 
Many thanks Ron. (Many of these macros already include snippets of code you
have posted. )




All times are GMT +1. The time now is 09:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com