Solved

Calling sub routine from a module

Posted on 2013-10-28
3
255 Views
Last Modified: 2013-10-28
Folks,
When I activate a worksheet  I call "NotifyUserGeneral":
Private Sub Worksheet_Activate()
NotifyUserGeneral
End Sub

Open in new window

I have a module that contains "NotifyUserGeneral" below:
Option Explicit
Private mMessageDisplayed As Boolean
-----------------------------------------------------------------------
Private Sub Worksheet_Activate()
    NotifyUserGeneral
End Sub
-----------------------------------------------------------------------
Private Sub NotifyUserGeneral()
If ActiveSheet.ProtectContents = True And Not mMessageDisplayed Then
    MsgBox "Except for the data cells shaded in light blue with black font the rest of this worksheet is protected!"
    mMessageDisplayed = True
End If
End Sub
---------------------------------------------------------------------------
Private Sub NotifyUserCell()
If ActiveSheet.ProtectContents = True And ActiveCell.Locked = True Then
    Msbbox "That cell is protected and cannot be changed!"
End If
End Sub
----------------------------------------------------------------------------------------------------------

Open in new window

However, I keep getting "Sub or Function not defined"  error when I activate the worksheet?
0
Comment
Question by:Frank Freese
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39605869
Hi,

Private before your sub means that it can only be used in the module .

so change to

Sub NotifyUserGeneral()
If ActiveSheet.ProtectContents = True And Not mMessageDisplayed Then
    MsgBox "Except for the data cells shaded in light blue with black font the rest of this worksheet is protected!"
    mMessageDisplayed = True
End If
End Sub

Open in new window


Regards
0
 

Author Comment

by:Frank Freese
ID: 39605898
You nailed it!
Thanks
0
 

Author Closing Comment

by:Frank Freese
ID: 39605899
thank you very much
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 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