Buttons to change font colour

trevolly

Board Regular
Joined
Aug 22, 2021
Messages
120
Office Version
  1. 365
Platform
  1. Windows
Good Evening all.

I’m wondering if anyone can help a beginner with Excel. At work we use an excel spreadsheet that we write a daily log on to. We basically type text in to text wrapped cells for each event that happens on the airfield I work at. I would like to be able to make some custom buttons that will change the font colour after you’ve typed the event in to the cell / log. This font colour change would be after I have typed the text in to the cell. For example if there was an emergency on the airfield we would type up what happened, then select the cell (not highlight all the text in the cell) and then press the custom made button which would turn all the text in the selected cell red (and maybe bold).

If anyone could help I’d be very grateful.

Regards.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Assign this macro to the button...
VBA Code:
Sub TurnSelectedCellRed()
  Selection.Font.Color = vbRed
End Sub
 
Upvote 0
The macro recorder is your best friend
 
Upvote 0
Solution
Two subroutines, one that you run to add a button, the other one will execute when you click the button.

After button has been added, just select a cell that you want to change and then click the button.

VBA Code:
Sub Add_Red_Text_Button_To_Active_Sheet()
'
    Dim WS  As Worksheet
    Dim oOLE As Excel.Button
'
    Set WS = Sheets(ActiveSheet.Name)                                                   ' <--- Change 'ActiveSheet.Name to another sheet name if desired
'
    Set oOLE = WS.Buttons.Add(Left:=350, Top:=35, Height:=18.75, Width:=150)     ' <--- Change settings to fit your needs
    oOLE.Caption = "Current Cell Red Text"
    oOLE.OnAction = "RedAndBold"
End Sub

Private Sub RedAndBold()
    With ActiveCell
    .Font.Color = vbRed
    .Font.Bold = True
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,573
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top