Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Private vs. Public VB problem in Excel 2007

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Private vs. Public VB problem in Excel 2007

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.

--
Regards;
Mark Rosenkrantz
--
Spreadsheet Solutions
Uithoorn
Netherlands (Those who live some 18 feet below sea level)
--
E:
W:
www.spreadsheetsolutions.nl
--
"Frustratedw/07" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Private vs. Public VB problem in Excel 2007


Procedures marked Private can be accessed only from code within the
same module. They cannot be found by code in any other module. See
http://www.cpearson.com/Excel/Scope.aspx for more details.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Wed, 4 Feb 2009 07:20:02 -0800, Frustratedw/07
wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Private vs Public Class Modules Ronald R. Dodge, Jr.[_2_] Excel Programming 8 January 21st 09 11:47 PM
Declaring subs Public vs Private Rick Excel Programming 9 December 19th 07 12:30 AM
difference between a private sub and a public function? Dave F Excel Discussion (Misc queries) 4 March 16th 07 07:38 PM
public but private variables No Name Excel Programming 2 May 19th 04 12:41 PM
Public subroutine called from a private sub Neil Bhandar[_2_] Excel Programming 1 January 15th 04 10:23 PM


All times are GMT +1. The time now is 07:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"