Solved

Save on ActiveWorksheet

Posted on 2011-09-02
1
300 Views
Last Modified: 2012-05-12
Hi Experts,

I need script that will not allow you to save or close out a file if you are on a active worksheet with the the word WIRE in it for exampe.

If I'm on worksheet BLUEWIRE, I cannot save until I go to the worksheet named BLUE.
0
Comment
Question by:mato01
1 Comment
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 125 total points
ID: 36474232
In thisworkbook code module:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    If InStr(lcase(ActiveSheet.Name), "wire") > 0 Then Cancel = True
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If InStr(lcase(ActiveSheet.Name), "wire") > 0 Then Cancel = True
End Sub

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delete all words in cell more than 5 words 7 47
DBF to ... Converter 5 43
Freeze Panes Solution 6 28
Excel:  Find text between 2nd hyphen and next space 10 30
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now