Creating A Color Picker Dialog Box
Category: UserForms | [Item URL]
A companion file is available: Click here to download
How it works
The example file contains the following:
- A UserForm (UserForm1) that contains a dialog box with 56 buttons.
- A Class Module (Class1) that defines a ColorButton Class.
- A VBA module (Module1) that contains a function (GetAColor).
- Two example subroutines that demonstrate the GetAColor function.
The GetAColor function sets up the dialog box and display it (see the figure below). The function returns the color value of the selected button. If the user clicks Cancel, the GetAColor function returns False. As the user moves the mouse pointer over the color buttons, the Color Sample image displays the color.
Using the function
To use the GetAColor function in your own workbooks, export UserForm1,
Module1, and Class1, and then import them into your workbook. Write your own
subroutine that calls the GetAColor function.
Excel Tips
Excel has a long history, and it continues to evolve and change. Consequently, the tips provided here do not necessarily apply to all versions of Excel.
In particular, the user interface for Excel 2007 (and later), is vastly different from its predecessors. Therefore, the menu commands listed in older tips, will not correspond to the Excel 2007 (and later) user interface.
All Tips
Browse Tips by Category
Search for Tips
Tip Books
Needs tips? Here are two books, with nothing but tips:
Contains more than 200 useful tips and tricks for Excel 2007 | Other Excel 2007 books | Amazon link: John Walkenbach's Favorite Excel 2007 Tips & Tricks
Contains more than 200 useful tips and tricks for Excel | Other Excel 2003 books | Amazon link: John Walkenbach's Favorite Excel Tips & Tricks

