Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Save on ActiveWorksheet

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
mato01
Asked:
mato01
1 Solution
 
Chris BottomleyCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now