Excel VBA, Get Color Code

This article provides a sample for getting the desired color code. The user selects a fill color for the cell A1. After pressing the Get Code button the color code used will be printed in cell B1.

It can be seen from the figures below that after the user selects a fill color for the cell A1 and presses the Get Code button the color code is printed in cell B1:

Color code 15773696:

Excel VBA, Get Color Code 1
Color code 52879:

Excel VBA, Get Color Code 2
Color code 65535:

Excel VBA, Get Color Code 3
The program uses a Button_Click event handler. Whenever the user presses the Get Code button the event handler is executed:

'executes whenever the user presses the Get Code
'button
Private Sub btnRun_Click()
'gets the color code used to fill cell A1a
Cells(1, 2) = Range("A1").Interior.Color
End Sub

You can download the file and code related to this article here.

See also:

If you need assistance with your code, or you are looking for a VBA programmer to hire feel free to contact me. Also please visit my website www.software-solutions-online.com

Leave a Reply

Your email address will not be published. Required fields are marked *