index match extract cells with certain font color

hajiali

Well-known Member
Joined
Sep 8, 2018
Messages
624
Office Version
  1. 2016
Platform
  1. Windows
Hello all Im looking to see how I can extract cells with certain font ColorIndex.

I have the Following Macro

VBA Code:
Function GetFontColor(ByVal Target As Range) As Integer
    GetFontColor = Target.Font.ColorIndex
End Function

The formula i have tried did not work. in my example I'm trying to get all Names if the font color EList[[F1]:[F10] appears the 41 color index

Excel Formula:
=INDEX(EList[LAST, FIRST],AGGREGATE(15,6,(ROW(EList[LAST, FIRST])-ROW(F2)+1)/(GetFontColor(EList[[F1]:[F10]])=41),ROWS(X15:X15)))

any help is greatly appreciated.

Thanks,
 
Thanks Fluff. Changing my basic Function to yours works like magic. I really Appreciate it.
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Glad we could help & thanks for the feedback.
 
Upvote 0
Hello Fluff the only issue I'm having is the formula that I have is not being updated as the data is being entered. I have made sure that the Calculation Options is set to Automatic and even when I try to hit Calculate Now it does not appear. I have to recopy the formula on the FHL sheet in order for the values to appear. not sure if the Function can be updated to fix this or is there another route.
 
Upvote 0
You can try
VBA Code:
Function GetFontColor(ByVal Rng As Range) As Variant
    Dim i As Long, j As Long
    Dim Ary As Variant
    
    Application.Volatile
    ReDim Ary(1 To Rng.Rows.Count, 1 To Rng.Columns.Count)
    For i = 1 To UBound(Ary)
      For j = 1 To UBound(Ary, 2)
         Ary(i, j) = Rng(i, j).Font.ColorIndex
      Next j
   Next i
   GetFontColor = Ary
End Function
But you will still have to use F9 to force a recalc.
 
Upvote 0
Thanks that will be easy fix I just included the recalculate into the coding. Works great!
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

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