Get the current Fill Color

Zhulu

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.

user8241870

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"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related