LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default losing command button functionality

Hi, my question is this:

I recorded a few macros for clearing the contents in ranges of cells.
I gave the ranges names, ie. "cellstoclearplow" These macros perform
fine.

Next, I placed Command Buttons from the Controls toolbox (not Forms
toolbox) on the sheet. I followed the "view code" link on their right-
click menus, and inserted the macro names into their respective VBA
scripts. The macros fired flawlessly now when clicking on the command
buttons.

The problem occurs when I close the worksheet, then re-open: Most,
but not all, of the Command buttons:

1. No longer fire their assigned macros, EVEN THOUGH all the code is
visible and unchanged in the VBA editor

2. No longer behave like Controls, but instead behave like 'pictures'
- the right-click context menu is the one I would get if I had used
Command Buttons from the Forms toolbox instead of from Controls
Toolbox - (and, by the way, this same loss of function occurs even if
I start out with Forms Command Buttons; that is, they will lose their
association with the macros I assigned once I close and reopen the
sheet; and yes, I'm careful to save the file before closing)

I know about being in and out of Design Mode, so that is not
interfering
I know about unprotecting the sheet, so that is not an issue

My hunch is that in the VBA code I need to associate the Command
Buttons and/or macros with active sheet. Does this sound plausible?
Here is an example of what I've got:

First the 3 declared macros:

Sub ClearPlowCells()
' ClearPlowCells Macro
' Macro recorded 10/21/2009 by James J

Application.Goto Reference:="cellstoclearplow"
Selection.ClearContents
End Sub

Sub clearshovelcells()
' clearshovelcells Macro
' Macro recorded 10/21/2009 by James J

Application.Goto Reference:="cellstoclearshovel"
Selection.ClearContents
End Sub

Sub ClearMeltCells()
Application.Goto Reference:="cellstoclearmelt"
Selection.ClearContents
End Sub

Now here are the associated Command Buttons:

Private Sub CommandButton2_Click()
ClearPlowCells
End Sub

Private Sub CommandButton3_Click()
clearshovelcells
End Sub

Private Sub CommandButton4_Click()
ClearMeltCells
End Sub
 
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
command button add another command Wanna Learn Excel Discussion (Misc queries) 5 December 7th 08 11:42 PM
Command Button Help Kenny Excel Discussion (Misc queries) 2 October 15th 07 03:29 AM
Losing Add-Inn Functionality Ben Excel Discussion (Misc queries) 0 April 20th 05 06:06 AM
Command Button Mark New Users to Excel 2 March 23rd 05 10:33 AM
Losing scroll functionality - weird Mike R. Excel Discussion (Misc queries) 2 March 10th 05 03:43 PM


All times are GMT +1. The time now is 08:03 AM.

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"