Cell font color function

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I'd like to create a function which returns the number 1 if the TEXT of a cell in the preceding column is red.

Is it possible to do this with VBA?

I was thinking of writing something along these lines, but would appreciate any pointers!

Thanks in advance.

HTML:
Function FontDetect()

          if activecell.font.color  = vbRed then 

          activecell.offset(0,1).value = 1

          else 

          end if
 
End Function
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Maybe something like this

Code:
Sub Main()
    Dim myRange As Range
    
    Set myRange = Range("A2:A10")
    FontDetect myRange
End Sub

Sub FontDetect(r As Range)
    Dim rCell As Range

    For Each rCell In r
        If rCell.Font.Color = vbRed Then rCell.Offset(0, 1) = 1
    Next rCell
End Sub

M.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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