Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Activating/De-activating buttons

Is there a way to activate a macro button based on a value in a cell and then
de-activating the button if the value does not match?

Thanks,


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Activating/De-activating buttons

if the button objet vba's name is commandbutton1 on the Sheet1 object then:

Sheet1.CommandButton1.Enabled = false ' or true

the change event of this sheet may be used to detect a change on that sheet

example:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Intersect(Target, Range("A1")) Is Nothing) Then
CommandButton1.Enabled = Not CommandButton1.Enabled
End If
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Activating/De-activating buttons

How do I find the name of the button? Thanks,


"abcd" wrote:

if the button objet vba's name is commandbutton1 on the Sheet1 object then:

Sheet1.CommandButton1.Enabled = false ' or true

the change event of this sheet may be used to detect a change on that sheet

example:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Intersect(Target, Range("A1")) Is Nothing) Then
CommandButton1.Enabled = Not CommandButton1.Enabled
End If
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Activating/De-activating buttons

Usually, the name is written inside the button when created. But you
also can find it in the VBA editor (the dropdown list: as you have
"General" or "worksheet" you now have the button object in the list. )

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Activating/De-activating buttons

If you mean a macro button on a command bar, I do not know how to do that
because I think they are either visible (added to the command bar) or not. I
don't think they can be disabled.


Assuming the "macro button" is a command button on a worksheet, yes.

Private Sub Worksheet_Change(ByVal Target As Range)

'test this by changing the value in cell A1
Const strTestValue = 5 'For example only

If ActiveSheet.Range("A1") = AcceptValue Then
CommandButton1.Enabled = True
Else
CommandButton1.Enabled = False
End If

End Sub



"Nash" wrote in message
...
Is there a way to activate a macro button based on a value in a cell and
then
de-activating the button if the value does not match?

Thanks,




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
Activating Workbooks Sungibungi Excel Discussion (Misc queries) 2 June 5th 09 04:22 AM
Activating Function Nat Excel Worksheet Functions 7 September 27th 06 07:54 AM
List box not activating sue74 Excel Discussion (Misc queries) 0 November 8th 05 01:34 PM
Activating a Hyperlink Jeremy S Excel Discussion (Misc queries) 3 July 3rd 05 02:15 AM
Worksheet activating JamesM Excel Programming 0 September 28th 04 03:55 PM


All times are GMT +1. The time now is 02:11 AM.

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"