I have a few buttons on an Excel worksheet that I want to change colour (black / red ) depending on a code. The goal of my routine is to make all 5 buttons black first and then make a selected one red.
Here is the the subprogram that I made using code that was recorded when I manually changed the colour of a button. Unfortunately, there no instruction to change the text colour was recorded. All help would be greatly appreciated.
![]()
Sub make1RedBtn(btnName As String, code As Integer) Dim newStyle As String Dim newColour As Integer Dim newSize As Integer If code = 0 Then newStyle = "Regular" newSize = 11 newColour = 0 ' Black? Else newStyle = "Bold" newSize = 12 newColour = 3 ' Red? End If ActiveSheet.Shapes.Range(Array(btnName)).Select With Selection.Characters(Start:=1, Length:=3).Font ' all buttons have 3 chars .FontStyle = newStyle .Size = newSize .ColorIndex = newColour ' <==== This line does not seem to work for me. End With End Sub











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks