Lesson#126: Making a simple color tester with VBA

Lesson#126: Making a simple color tester with VBA

Here I will show you how to make a simple color tester with VBA.

This color tester is having only one big button. It will take input from the user for the value of Red, Green, and Blue. Then it will color the whole worksheet.

For this, you have to insert a button from the Developer tab and put a simple macro in it.

Sub Button1_Click()
Dim rgb1, rgb2, rgb3 As Integer
rgb1 = InputBox(“Input the value of Red between to 255”, “Red”)
rgb2 = InputBox(“Input the value of Green between to 255”, “Green”)
rgb3 = InputBox(“Input the value of Blue between to 255”, “Blue”)
Range(“A1:XFD1048576”).Interior.Color = RGB(rgb1, rgb2, rgb3)
End Sub

Now another type of color tester for you.

Here I have designated cells for the input of values of Red, Green, and Blue and made a data validation. The designated certain range for showing the color. Inserted a button and put this macro.

Sub Button1_Click()
Dim rgb1, rgb2, rgb3 As Integer
rgb1 = Range(“F3”)
rgb2 = Range(“F4”)
rgb3 = Range(“F5”)
Range(“G3:I5”).Interior.Color = RGB(rgb1, rgb2, rgb3)
End Sub

Here is the file for you.

Never forget to save these files in .xlsm format after using VBA.

See also  Lesson#96: How to HLOOKUP chart from a drop-down menu in Excel

Hi! I am Puspendu. I am the founder and author of Excelabcd. I am little creative person, blogger and Excel-maniac guy. I hope you enjoy my blog.

Leave a Reply

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

*