Solved

Calling sub routine from a module

Posted on 2013-10-28
3
247 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

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

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

895 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

17 Experts available now in Live!

Get 1:1 Help Now