#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 90
Default Command Button Help

I have several command buttons that I need to enable and disable depending on
the one that is clicked currently my code reads like this.

CommandButton1 Click()
CommandButton1.Enabled = False 'because it was clicked
CommandButton2.Enabled = Ture 'because now it can be clicked
CommandButton2.Enabled = Ture 'because now it can be clicked
CommandButton2.Enabled = Ture 'because now it can be clicked

This continues for every commandbutton click procedure. I would like to
rewrite the code to go something like this but I cannot get it to work.
Please Help

Option Explicit
Dim Choice

CommandButtonChoice Sub()
CommandButton1.Enabled = True
CommandButton2.Enabled = True
CommandButton3.Enabled = True
CommandButton4.Enabled = True
Choice.Enabled = False <=============This turns the choice off
End Sub

CommandButton1 Click()
Choice=CommandButton1 <=============Choice to turn off
Call CommandButtonChoice
End Sub

Repeat for each click procedure

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,510
Default Command Button Help

Hi again Kenny,

I assume that this is a follow on from my last reply to you. You need to use
Set when assigning and object to a variable.

Option Explicit
Dim Choice As Object

Sub CommandButtonChoice()
MsgBox "CommandButtonChoice() called"
CommandButton1.Enabled = True
CommandButton2.Enabled = True
CommandButton3.Enabled = True
CommandButton4.Enabled = True
Choice.Enabled = False
End Sub

Sub CommandButton1_Click()
MsgBox "CommandButton1_Click()"
Set Choice = CommandButton1
Call CommandButtonChoice
End Sub

Regards,

OssieMac


"Kenny" wrote:

I have several command buttons that I need to enable and disable depending on
the one that is clicked currently my code reads like this.

CommandButton1 Click()
CommandButton1.Enabled = False 'because it was clicked
CommandButton2.Enabled = Ture 'because now it can be clicked
CommandButton2.Enabled = Ture 'because now it can be clicked
CommandButton2.Enabled = Ture 'because now it can be clicked

This continues for every commandbutton click procedure. I would like to
rewrite the code to go something like this but I cannot get it to work.
Please Help

Option Explicit
Dim Choice

CommandButtonChoice Sub()
CommandButton1.Enabled = True
CommandButton2.Enabled = True
CommandButton3.Enabled = True
CommandButton4.Enabled = True
Choice.Enabled = False <=============This turns the choice off
End Sub

CommandButton1 Click()
Choice=CommandButton1 <=============Choice to turn off
Call CommandButtonChoice
End Sub

Repeat for each click procedure

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 90
Default Command Button Help

This worked thanks!


"OssieMac" wrote:

Hi again Kenny,

I assume that this is a follow on from my last reply to you. You need to use
Set when assigning and object to a variable.

Option Explicit
Dim Choice As Object

Sub CommandButtonChoice()
MsgBox "CommandButtonChoice() called"
CommandButton1.Enabled = True
CommandButton2.Enabled = True
CommandButton3.Enabled = True
CommandButton4.Enabled = True
Choice.Enabled = False
End Sub

Sub CommandButton1_Click()
MsgBox "CommandButton1_Click()"
Set Choice = CommandButton1
Call CommandButtonChoice
End Sub

Regards,

OssieMac


"Kenny" wrote:

I have several command buttons that I need to enable and disable depending on
the one that is clicked currently my code reads like this.

CommandButton1 Click()
CommandButton1.Enabled = False 'because it was clicked
CommandButton2.Enabled = Ture 'because now it can be clicked
CommandButton2.Enabled = Ture 'because now it can be clicked
CommandButton2.Enabled = Ture 'because now it can be clicked

This continues for every commandbutton click procedure. I would like to
rewrite the code to go something like this but I cannot get it to work.
Please Help

Option Explicit
Dim Choice

CommandButtonChoice Sub()
CommandButton1.Enabled = True
CommandButton2.Enabled = True
CommandButton3.Enabled = True
CommandButton4.Enabled = True
Choice.Enabled = False <=============This turns the choice off
End Sub

CommandButton1 Click()
Choice=CommandButton1 <=============Choice to turn off
Call CommandButtonChoice
End Sub

Repeat for each click procedure

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
Command button AOU Excel Discussion (Misc queries) 2 September 14th 07 06:32 PM
Command Button inspirz Excel Discussion (Misc queries) 1 March 29th 07 06:38 PM
VBA Command Button IntricateFool Excel Discussion (Misc queries) 5 December 8th 06 04:39 AM
command button Zygan Excel Discussion (Misc queries) 0 June 30th 06 01:59 AM
Command Button Chris Hale Excel Discussion (Misc queries) 1 February 10th 05 05:14 AM


All times are GMT +1. The time now is 08:41 PM.

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

About Us

"It's about Microsoft Excel"