Home » excel » excel – Get the current Fill Color

excel – Get the current Fill Color

Posted by: admin April 23, 2020 Leave a comment


How can I get the current Fill Color in the ribbon using VBA? I like to manually select the Fill color to highlight entire rows with. I know I can highlight an entire row with code like foo.EntireRow.Interior.ColorIndex = 3. However, instead of setting it to 3, I want to set it to the user’s currently selected Fill Color in the ribbon.

I found a similar thread for Microsoft Word that uses Options.DefaultHighlightColorIndex, but I have not found one for Microsoft Excel.

Edit: Sorry for the duplicate question. I am hoping there’s a better answer that doesn’t require an active selection first. If not I’ll accept Jonathan’s answer. Currently I am just highlighting the current cell with CellFillColorPicker, getting that cell’s color and then highlighting the row with that color.

How to&Answers:

This question appears to be similar to this one: VBA – use color already select in Excel to fill cell interior

It looks like this is the code that you want:

Application.CommandBars.ExecuteMso “CellFillColorPicker”