Zhulu
Zhulu

Reputation: 155

Get the current Fill Color

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.

Upvotes: 4

Views: 706

Answers (1)

user8241870
user8241870

Reputation:

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"

Upvotes: 1

Related Questions