How do I change a buttons contents depending on a cells contents?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to change the contents (and format if possible) depending on the
contents of a cell... If possible, the button would only display in certain
cells contained data.

Is this possible?

Thanks,

Tim
 
some thing like this in the Sheet Object where the button is located:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Range("C3") = "Hello" Then
ActiveSheet.Shapes("MyBtn").Visible = True
'vba seems to require selection before formatting, so:
ActiveSheet.Shapes("MyBtn").Select
With Selection.Font
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 3
End With
Target.Select
Else
ActiveSheet.Shapes("MyBtn").Visible = False
End If
Application.EnableEvents = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top