VBA to ALWAYS see six default colors

trevhill

Board Regular
Joined
May 27, 2009
Messages
93
I'm making presentations all day at work. A ton of graphs in excel 2003.

I'd like to write VBA, on the global level (meaning its always 'on' whenever I use excel) that makes sure there are six default colors in my palette.

So that whenever I want to modify a bar chart, and I pop into the default color changing form, the same six colors show up.

Any ideas on how to start?

Thanks,
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Here is a article on the Excel color palette.
http://support.softartisans.com/kbview_1205.aspx

The procedure below customizes the Excel colour palette to display red, green, blue across the top row.

Once modified to meet your needs, you can either save the workbook as a template or use it as an Add-In.

To use the code place it it the ThisWorkbook module.
Code:
[COLOR=darkblue]Private[/COLOR] [COLOR=darkblue]Sub[/COLOR] Workbook_Open()
   MyColourPalette
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
 
[COLOR=darkblue]Sub[/COLOR] MyColourPalette()
   [COLOR=darkblue]Dim[/COLOR] myPalette
   myPalette = ActiveWorkbook.Colors
   [COLOR=green]'row 1 colours[/COLOR]
   myPalette(1) = RGB(255, 0, 0)    [COLOR=green]'red[/COLOR]
   myPalette(53) = RGB(0, 255, 0)   [COLOR=green]'green[/COLOR]
   myPalette(52) = RGB(0, 0, 255)   '[COLOR=green]blue[/COLOR]
   myPalette(51) = RGB(255, 0, 0)   [COLOR=green]'red[/COLOR]
   myPalette(49) = RGB(0, 255, 0)   [COLOR=green]'green[/COLOR]
   myPalette(11) = RGB(0, 0, 255)   [COLOR=green]'blue[/COLOR]
   myPalette(55) = RGB(255, 0, 0)   [COLOR=green]'red[/COLOR]
   myPalette(56) = RGB(0, 255, 0)   [COLOR=green]'green[/COLOR]
' etc
 
   ActiveWorkbook.Colors = myPalette
[COLOR=darkblue]End[/COLOR] Sub
Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,214,849
Messages
6,121,925
Members
449,056
Latest member
denissimo

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