Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hiya all!
Is it possible to chnage the name of a command button to something thats in a cell? example. I have a cell with a product name in it but this name needs to be the name of the command button so you know what button your pressing, but as this product name changes I need the name of the button to change too without doing it manually. Is this possible? --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 080108-0, 08/01/2008 Tested on: 09/01/2008 08:26:41 avast! - copyright (c) 1988-2008 ALWIL Software. http://www.avast.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private prev As Variant
Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "H1:H10" '<== change to suit On Error GoTo ws_exit Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target Me.Buttons(prev).Name = .Value End With End If ws_exit: Application.EnableEvents = True End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Cells.Count 1 Then Exit Sub prev = Target.Value End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Steve" wrote in message ... Hiya all! Is it possible to chnage the name of a command button to something thats in a cell? example. I have a cell with a product name in it but this name needs to be the name of the command button so you know what button your pressing, but as this product name changes I need the name of the button to change too without doing it manually. Is this possible? --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 080108-0, 08/01/2008 Tested on: 09/01/2008 08:26:41 avast! - copyright (c) 1988-2008 ALWIL Software. http://www.avast.com |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If I understand what you want correctly, I think this code will work for you...
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$A$1" Then CommandButton1.Caption = Target.Value End Sub Note: This assume the Command Button is an ActiveX one (that is, **not** from the Forms toolbar). Change the "$A$1" to whatever cell address your product name is in... just make sure to use an absolute address (that is, with the $ signs as shown). Rick "Steve" wrote in message ... Hiya all! Is it possible to chnage the name of a command button to something thats in a cell? example. I have a cell with a product name in it but this name needs to be the name of the command button so you know what button your pressing, but as this product name changes I need the name of the button to change too without doing it manually. Is this possible? --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 080108-0, 08/01/2008 Tested on: 09/01/2008 08:26:41 avast! - copyright (c) 1988-2008 ALWIL Software. http://www.avast.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Wanting to Create A Command Button Command | Excel Programming | |||
VB's Command Button vs Form's Command Button | Excel Programming | |||
Command Button vs Form Button | Excel Programming | |||
Command Button vs Control Button | Excel Programming | |||
Command Button vs Form Button | Excel Programming |