Location>code7788 >text

Using the custom ribbon to complete the Excel two colors staggered fill

Popularity:686 ℃/2024-10-12 12:01:26

Today you need to use the fill color in Excel to complete the two colors of the interleaved fill

In excel, after selecting a color to fill, then switch to another color and click fill again. The operation will look clunky

 

So the idea was born, is it possible to add a small square similar to a fill color and put another color in it through Excel's custom ribbon?

The answer is no. Because Excel's default color picker for 1 color, the default fill color is a key. Then neither by adding a key, nor by adding an alternate color to complete the filling of the two colors.

Immediately after that came the thought of the almighty macro.

Customize Ribbon + Macro allows customized macro functions to be added to Excel's menu bar like a menu. However, there is a drawback in that the two macros shown above actually pop up to view the macros when clicked. With the current version, Excel cannot add each individual macro module button.

I defined two macros: 1, fill foreground color, 2, fill background color. (foreground color and background color may not be called properly, here I use them to indicate two colors, after the PS kind of foreground color / background color)

The VBA code to set the selected area fill color is as follows:

Sub Fill Foreground Color()
Dim rng As Range
    Set rng = Selection
     = RGB(146, 208, 80) ' Set to foreground color #92D050
End Sub

This allows you to quickly fill two or even more colors by clicking the "Macro" button on the menu!

 

P.S.: The color code can be viewed by selecting the color and clicking Excel Fill Color - & gt; Other Colors - & gt; Custom inside the hexadecimal and RBG format corresponding to the number.