LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Command Button problems

Richard,

Sounds like you want the code to run based on the
Worksheet that is currently active.
I do this all the time. Try this:
1. Take the code out of the Worksheet and put it in a
Module.
T
2. hen add this at the beginning:
mySheetName = ActiveCell.Worksheet.Name

3. Then find all the places in the existing code where
the name of a worksheet is hardcoded in and replace then
with:
mySheetName

4. Then from each command button click event, just call
the code.

Please let me know if you have any questions,
Ed

-----Original Message-----
Hello,
I have a workbook called Allotment which contains two
spreadsheets called All and Update.

Update has two CommandButtons called OptionA and OptionB.
In Update both buttons execute the code without a

problem.
I wish to be able to place both these buttons on sheet

All
and run then from there.

This is what I have done.

Opened control Toolbox in sheet Update and clicked on

the
OptionA button and selected copy. Then over to the All
sheet and clicked paste. Gone back to Update and copied
code over to the CommandButton in the All sheet.

When I click the command button in the All sheet, the
button is executing the code applicable to the Update
sheet within the All sheet. The first lines of code for
the Conmmand button delete cells in the Update sheet,
which is how it should, but when run from the All sheet

it
is deleting basically all of my sheet All, just leaving
some remnants of macro buttons etc.

What am I doing wrong. How can I drive the Update sheet
alone from the All sheet where I have copied the buttons
and code to. In other words the commands are executing

on
the wrong sheet.

Any help, please!
Thanks.
.

 
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
Command Button protection problems???? Chris Watson Excel Worksheet Functions 3 February 25th 06 03:24 PM
Command Button problems steve Excel Programming 3 September 17th 03 03:47 PM
Command Button vs Form Button T K Excel Programming 4 August 26th 03 07:26 PM


All times are GMT +1. The time now is 08:05 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"