Solved

Save on ActiveWorksheet

Posted on 2011-09-02
1
309 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

786 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