Button Text / Cell value

  • Thread starter Thread starter Martin D'sylva
  • Start date Start date
M

Martin D'sylva

Hi,

I have some buttons on my worksheet with macros assigned to them. Is it
possible for the text on the button to be called up from a cell, or is there
a workaround without the user having to run another macro to copy the cell
data to the button text?

Thanks in advance,
Martin
 
Hi Martin
one way: Use the worksheet change event of your worksheet. Put the
following code in your worksheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.count > 1 Then Exit Sub
If Intersect(Target, Me.Range("B1")) Is Nothing Then Exit Sub
If Target.Value <> "" Then
ActiveSheet.OLEObjects("commandbutton1").Object.Caption =
Target.Value
End If
End Sub

'Links the content of cell B1 to your commandbutton (assumption:
commandbutton1)
 
Back
Top