vba extract text color format

Dancarro

Board Regular
Joined
Feb 23, 2013
Messages
72
Hi guys,

I am trying to get a vba code to extract font color and it appears not be working.

1734437744476.png


The data is in column AI and I created column AJ 'Font color' but the vba code appears not to be working

=GetFontColor(AI3)
1734437875299.png


What I need to gain is to know the text color of the specific range of column AI? Any advice would be great.
Kind Regards,
Dan
 
You could run this little procedure to populate column AJ with the font color from column AI starting row row 3 and going down to the last row with data in column A1.
Just note that if you change any of the font colors after the fact, you will need to call/run the procedure again:
VBA Code:
Sub PopulateFontColors()

    Dim lr As Long
    Dim r As Long
   
    Application.ScreenUpdating = False
   
'   Find last row with data in column A1
    lr = Cells(Rows.Count, "AI").End(xlUp).Row
   
'   Loop through all rows starting with row 3 and populate font color in column AJ
    For r = 3 To lr
        Cells(r, "AJ").Value = Cells(r, "AI").Font.ColorIndex
    Next r
   
    Application.ScreenUpdating = True
   
End Sub
So does that do what you need?
Hi Joe, it works perfectly. Thank you so much
 
Upvote 0

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
You could run this little procedure to populate column AJ with the font color from column AI starting row row 3 and going down to the last row with data in column A1.
Just note that if you change any of the font colors after the fact, you will need to call/run the procedure again:
VBA Code:
Sub PopulateFontColors()

    Dim lr As Long
    Dim r As Long
   
    Application.ScreenUpdating = False
   
'   Find last row with data in column A1
    lr = Cells(Rows.Count, "AI").End(xlUp).Row
   
'   Loop through all rows starting with row 3 and populate font color in column AJ
    For r = 3 To lr
        Cells(r, "AJ").Value = Cells(r, "AI").Font.ColorIndex
    Next r
   
    Application.ScreenUpdating = True
   
End Sub
So does that do what you need?
Hi Joe, it works perfectly. Thank you so much.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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