Private vs. Public VB problem in Excel 2007

  • Thread starter Thread starter Frustratedw/07
  • Start date Start date
F

Frustratedw/07

In Excel 2003 I created macros tied to command buttons that are tied to the
worksheet and shown as a Private sub. This macro will not run past through
the Range statement below in 2007. If I change it to a Public sub in a
module it works. How can I keep the code tied to the command button and why
doesn't it work anymore?

Private Sub SortbyCIGreenCommandButton7_Click()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Worksheets("JAN").Activate
Range("G4:BB4").Select
With Selection
 
Private sub's can be triggered from the module that they reside in.
Public Sub's can be triggered from any module.

It is actually an "environmental" issue.
Public is "a higher level " than private.

So in your case I think you tried to run a private routine from a module to
which it does not belong.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top