Implementing color schemes in my project

webster188

New Member
Joined
Oct 20, 2010
Messages
31
Hi All,

I have a rather big vba project that is used by multiple users. The different worksheets and userforms all have a uniform look and feel. Used colors are defined by RGB values.

In my current code, the used colors are hard coded. For instance, the background of each userform is set before the userform is displayed.

I now want to store the colors in a worksheet or as a constant in vba so I can refer to these values each time i need to display something. By doing so, I can also easily implement color schemes where the user can select what colors to be used.

What would be the easiest way to implement something like this.

Thank in advance for your help.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I would declare some global constants. For project-wide scope you put the constants at the top of a module and declare them as public.

Code:
Option Explicit

Public Const gAUBERGINE As Long = 3148587
Public Const gMAUVE As Long = 10978487
Public Const gPUCE as Long = 10062028

Sub ColorMePurple()
    ' Code here.
End Sub

I always use all uppercase for constants. For global variables and constants, I use a lowercase g as a prefix.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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