Changing a cell's font colour if it contains a value

DebN

New Member
Joined
Sep 21, 2020
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
Hello.
I already have code that puts a */ at the end of a cell's contents if that cell has a value in it. I was wondering if it would be possible to also change the font colour to red as well...? As you can see, I know next to nothing about VBA code....

This is the current code:

Sub addStarAndBackslashToEndofCell()
Dim e As Range
For Each e In Selection
If e.Value <> "" Then e.Value = e.Value & " */ "
Next
End Sub

Many thank-yous to anyone that gives it a go.
:)
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
How about
VBA Code:
Sub addStarAndBackslashToEndofCell()
   Dim e As Range
   For Each e In Selection
      If e.Value <> "" Then
         e.Value = e.Value & " */ "
         e.Font.Color = vbRed
      End If
   Next
End Sub
 
Upvote 0
Wow! Thanks so much! Exactly what I wanted. This makes my life so much easier. Thanks again.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

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