Excel supports more than 16 million colors in a cell; hence you should know how to set the exact color in a cell. To do this, you can use RGB (Red, Green, Blue) function in VBA to set the color of a cell. The function requires 3 numbers from 0 to 255 [e.g. RGB(234,232,98)]. Below is a practice code that changes cell colors to Green, Red and Blue.
'This function can be used to change the color of a cell
Public Sub ChangeCellColor()
'Change cell color to green
Sheet1.Range("C4").Interior.Color = RGB(0, 255, 0)
'Change cell color to red
Sheet1.Range("C5").Interior.Color = RGB(255, 0, 0)
'Change cell color to blue
Sheet1.Range("C6").Interior.Color = RGB(0, 0, 255)
End Sub
You can also read this post to know how to get RGB Codes of a Color.
VBA Code to Count Color Cell based on Conditional Formatting
Free File Renamer Tool – Quickly Rename files batch using Excel VBA Here is another help code and tool for programmers to rename files. You can use this tool for renaming all files available in…
Random Rows Selector is an MS Excel based tool which can be used to pick random or stratified samples from a set of records available in the Excel. The tool is fully dynamic, it can support any data format in Excel.
VBA Tools To Create Folders In VBA, you can use MkDir function to create folders in your system or shared drive. To make your work simple, we bring a free Excel VBA tool to create…
How to Find Duplicate Files In excel using VBA? Yesterday I was working on my computer and cleaning the drives to make some more space. I was surprised to see so many files saved at…
Random Rows Selector is an MS Excel based tool which can be used to pick random or stratified samples from a set of records available in Excel.
File Manager tool is an Excel based tool which helps you to delete or move unwanted files from your system. It requires a source and destination folder (in case you want to move files). First it lists all the files available in the folder or sub-folders then you can select the action to be taken for each file such as Move or Delete. With a click of button, tool will take all necessary actions.
One Comment