Solved

Save on ActiveWorksheet

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

743 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

9 Experts available now in Live!

Get 1:1 Help Now