Solved

Calling sub routine from a module

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

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

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

Suggested Solutions

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…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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 create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

746 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

16 Experts available now in Live!

Get 1:1 Help Now