• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
EDUCBA

EDUCBA

MENUMENU
  • Resources
        • Excel Charts

          • Histogram Chart Excel
          • Basic Excel Formulas
          • Text to Columns in Excel
        • Excel Charts
        • Excel Tips

          • Excel Gantt Chart
          • IFERROR with VLOOKUP
          • Data Table in Excel
        • Excel Tips
        • Excel Tools in Excel

          • Stacked Column Chart
          • Cheat Sheet of Excel Formulas
          • Excel Data Validation
        • Histogram chart in excel
        • Others

          • Resources (A-Z)
          • Excel Functions
          • Financial Functions in Excel
          • Logical Functions in Excel
          • Lookup Reference Functions in Excel
          • Maths Function in Excel
          • TEXT and String Functions in Excel
          • View All
  • Free Courses
  • All Courses
        • Certification Courses

          Excel Course 1
        • All in One Bundle

          All-in-One-Excel-VBA-Bundle
        • Excel course

          Excel-Training
        • Others

          • Excel advanced course
          • VBA Course
          • Excel Data Analysis Course
          • Excel for Marketing Course
          • Excel for Finance Course
          • View All
  • 120+ Courses All in One Bundle
  • Login

VBA Font Color

Home » Excel » Blog » VBA » VBA Font Color

VBA Font Color

VBA Font Color

VBA has a lot of commands and functions to play with. We can do anything in VBA and apply that to Excel. Applying VBA in Excel is the easiest and a fun thing. VBA also has the function by which we can change the color of cell, fonts and we can even bold the characters as well. VBA font color is used in different ways and it helps to change the color of the fonts in excel.

How to Color a Font Using VBA?

Let’s see the examples of font color in Excel VBA.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

You can download this VBA Font Color Excel Template here – VBA Font Color Excel Template

Example #1 – VBA Font Color

We have sample text in an Excel sheet with the text “VBA Font Color” in cell B3 as shown below. As we can see the color of the font is default black color in nature.

Font Color Example 1

To apply the VBA code for changing the color of fonts for above-shown text, we need a module.

Step 1: So for this go to the VBA window and click on Module option available in the Insert menu option as shown below.

Module for VBA Font Color

Step 2: Once we do that, we will get the blank window of Module. In that, start writing subcategory of VBA Font Color or in any other name as per your need as shown below.

Popular Course in this category
Cyber Week Sale
VBA Training (3 Courses, 12+ Projects) 3 Online Courses | 13 Hands-on Projects | 45+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.7 (2,738 ratings)
Course Price

View Course

Related Courses
Excel Advanced Training (14 Courses, 21+ Projects)Excel Data Analysis Training (12 Courses, 6+ Projects)

Code:

Sub VBAFontColor2()

End Sub

VBA Font Color Exmaple 1.1

Step 3: First select the range of the cell where the text is located. Here, our range will be cell B3 and that will be written followed by “.Select” command as shown below.

Code:

Sub VBAFontColor2()

Range("B3").Select

End Sub

VBA Font Color Exmaple 1.2

Step 4: As we need to change the color of fonts so we will select the Font command with the help of Selection as shown below.

Code:

Sub VBAFontColor2()

Range("B3").Select
Selection.Font

End Sub

VBA Font Color Exmaple 1.3

Step 5: After that, we will select the command Color separated by a dot (.) as shown below.

Code:

Sub VBAFontColor2()

Range("B3").Select
Selection.Font.Color

End Sub

VBA Font Color Exmaple 1.4

Now to understand the formation of any color, in VBA we have RGB i.e. Red-Green-Blue. Numeric values of each color range from 0 to 255. Suppose we need to change to a color font to Black then RGB value will be RGB(0, 0, 0). As we already have the black color font we will try to select some other color.

Step 6: Let’s give the largest value to Green color and least to Red and zero to Blue color. As per that, considering Red at 20, Green at 230 and Blue at zero as shown below.

Code:

Sub VBAFontColor2()

Range("B3").Select
Selection.Font.Color = RGB(20, 230, 0)

End Sub
VBA Font Color Exmaple 1.5

Step 7: Now compile the code to find if it has any error and then run by clicking on the play button located below the menu bar. We will apply font color for text which is in cell B3 and now changed from Black to Green color.

VBA Font Example1

Example #2 – VBA Font Color

There is another way of changing the font color in VBA. For this, we will consider the same text as shown in example-1 located in cell B3.

Color Example 2

Apart from RGB, we can change the color of fonts with the keyword “vb” followed by the name of the color. But by this process, we can only get the main basic color as the font color. Where with the help of RGB we could get color of any shade, just by putting the different values for Red, Green and Blue colors.

The color which can be used with vb are Black, Blue, Cyan, Green, Magenta, Red, White, and Yellow. And how to select the color in format is shown below.

diff color

Step 1: To apply this, go to VBA to create the subcategory in the name of VBA Font Color or in any other name in a new module as shown below.

Code:

Sub VBAFontColor3()

End Sub

VBA Font Color Exmaple 2.1

Step 2: Select the range of cell for which we need to change the font color as shown below.

Code:

Sub VBAFontColor3()

Range("B3").Select

End Sub

VBA color Example 2.1

Step 3: In the same manner what we have seen in example-1, use selection function with Font and Color to activate them.

Code:

Sub VBAFontColor3()

Range("B3").Select
Selection.Font.Color

End Sub

VBA color Example 2.2

Step 4: It lets the color of font from Black to Cyan. For this select Cyan color by vbCyan as shown below.

Code:

Sub VBAFontColor3()

Range("B3").Select
Selection.Font.Color = vbCyan

End Sub

VBA color Example 2.3

Step 5: If required then we can compile the code and then run it. We will see the font color of text at cell B3 is changed from Black to Cyan.

VBA Example 2

Example #3 – VBA Font Color

Microsoft has defined a variety of color in different numbers. These are 56 in numbers. We can select any of the color code between to 1 to 56 to change the font color of any cell. These color codes are shown below.

100 color

Step 1: Now go to the VBA window and open a new module. In that write the Sub Category of VBA Font Color as shown below.

Code:

Sub VBAFontColor4()

End Sub

VBA Font Color Exmaple 3.1

Step 2: For this example, we will select the same text as seen in the above examples. Now select the range of the cell which is B3 as shown below.

Code:

Sub VBAFontColor4()

Range("B3").Select

End Sub

Exmaple 3.2

Step 3: Now in the second line, select the Font function with Selection command.

Code:

Sub VBAFontColor4()

Range("B3").Select
Selection.Font.

End Sub

VBA color Example 3.4

Step 4: To select and apply the above-shown color code, we need to select ColorIndex function instead of Color which we used in example 1 and 2.

Code:

Sub VBAFontColor4()

Range("B3").Select
Selection.Font.ColorIndex = 46

End Sub

Example 3.5

And at last, select the color code which we need to see in a selected range of cell. Let’s select color code 46 which is used for Orange color.

Step 5: Now run the code to see the change. We will the color font at cell B3 is now changed from black to orange.

VBA Font Example 3

Pros of VBA Font Color

  • It is easy to implement.
  • With the help of RGB, we can change the color of any shade we want.
  • It helps in creating the dashboard where we need to show the different types of data in a different color with the help of VBA.

Things to Remember

  • It is always recommended to use RGB when we do not know the color code. By giving a different color range from 0 to 255 in RGB we can create any color from dark to bright shade of our choice.
  • Saving the file in Macro Enable Excel helps to use and visit the written code multiple times.
  • Although changing font color in excel is the easiest way to do, but automating this activity in huge set of work can save the time and it will avoid the chances when the file may get crash or hang.

Recommended Articles

This is a guide to VBA Font Color. Here we discuss how to use Excel VBA Font Color along with few practical examples and downloadable excel template. You can also go through our other suggested articles –

  1. How to Use VBA While Loop?
  2. VBA Remove Duplicates
  3. Understanding VBA Data Types
  4. VBA Sleep with Examples

All in One Software Development Bundle (600+ Courses, 50+ projects)

600+ Online Courses

50+ projects

3000+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Reader Interactions
Leave a Reply Cancel reply

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

Primary Sidebar
Excel Functions Tutorials
  • VBA
    • VBA Max
    • VBA Environ
    • VBA Not
    • VBA LOOKUP
    • Programming in Excel
    • VBA Name Worksheet
    • VBA ScreenUpdating
    • VBA Do Loop
    • VBA Declare Array
    • VBA Macros
    • VBA Delete Sheet
    • VBA Editor
    • VBA Error Handling
    • VBA Goal Seek
    • VBA DateDiff
    • VBA On Error Resume Next
    • VBA Examples
    • VBA Counter
    • VBA Val
    • VBA Me
    • VBA Double
    • VBA Variable Types
    • VBA FreeFile
    • VBA Switch Case
    • VBA Unprotect Sheet
    • VBA Format Number
    • VBA ReDim
    • VBA IF Statements
    • VBA DoEvents
    • VBA Public Variable
    • VBA Columns
    • VBA Cdate
    • VBA Selection Range
    • VBA Hide Columns
    • VBA COUNTA
    • VBA Insert Row
    • VBA Protect Sheet
    • VBA AutoFill
    • VBA IF Not
    • VBA GetObject
    • VBA Debug Print
    • VBA Collection
    • VBA Text
    • VBA Randomize
    • VBA Variant
    • VBA Selection
    • VBA Right
    • VBA Date Format
    • VBA Rename Sheet
    • VBA Paste Values
    • VBA InputBox
    • VBA Conditional Formatting
    • VBA Pause
    • VBA Pivot Table
    • VBA Message Box
    • VBA OFFSET
    • VBA ByRef
    • FileCopy in VBA
    • VBA StrConv
    • VBA SUB
    • VBA Boolean
    • VBA Global Variables
    • VBA Worksheets
    • VBA IIF
    • VBA Close UserForm
    • VBA Variable Declaration
    • VBA Join
    • VBA Dictionary
    • VBA Operators
    • VBA Charts
    • VBA For Each Loop
    • VBA FileDialog
    • VBA Format
    • VBA MID
    • VBA GetOpenFileName
    • VBA DatePart
    • VBA Code
    • VBA Option Explicit
    • VBA FileSystemObject (FSO)
    • VBA ASC
    • VBA UserForm
    • VBA Cells
    • VBA InStrRev
    • VBA Class Module
    • VBA Constants
    • VBA Length of String
    • VBA DateSerial
    • VBA StrComp
    • VBA Array Length
    • VBA Check File Exists
    • VBA Ubound
    • VBA CDBL
    • VBA Activate Sheet
    • VBA DateValue
    • VBA Borders
    • VBA Comment
    • VBA Intersect
    • VBA Workbook
    • VBA Concatenate
    • VBA Name
    • VBA Find and Replace
    • VBA Tutorial
    • VBA CSTR
    • VBA Save As
    • VBA Hyperlink
    • VBA Print
    • VBA Switch
    • VBA END
    • VBA Like
    • VBA Set
    • VBA excel programming
    • VBA Call Sub
    • VBA Object
    • VBA RoundUp
    • VBA ArrayList
    • VBA Named Range
    • VBA PowerPoint
    • VBA Block Comment
    • VBA OverFlow Error
    • VBA Insert Column
    • VBA Lcase
    • VBA List Box
    • VBA Delete File
    • VBA Clear Contents
    • VBA TextBox
    • VBA Font Color
    • VBA Range Cells
    • VBA INT
    • VBA UCASE
    • VBA Value
    • VBA Remove Duplicates
    • VBA Break for Loop
    • VBA Sleep
    • VBA Do Until Loop
    • VBA Union
    • VBA Long
    • VBA Copy Paste
    • VBA Data Types
    • VBA Delete Column
    • VBA Enum
    • VBA IsEmpty
    • VBA 1004 Error
    • VBA RegEx
    • VBA IsNumeric
    • VBA Paste
    • VBA Transpose
    • VBA Left
    • VBA Delete Row
    • VBA Integer
    • VBA Active Cell
    • VBA InStr
    • VBA Round
    • VBA Subscript out of Range
    • VBA Dim
    • VBA Replace
    • VBA Sort
    • VBA String
    • VBA Split
    • VBA Wait
    • VBA MOD
    • VBA Time
    • VBA TIMER
    • VBA While Loop
    • VBA Date
    • Excel VBA MsgBox
    • VBA IFError
    • VBA Color Index
    • VBA Match
    • VBA Case
    • VBA Arrays
    • VBA GoTo
    • VBA On Error
    • VBA Range
    • VBA Do While Loop
    • VBA Number Format
    • VBA Loops
    • VBA TRIM
    • VBA Find
    • VBA Select Case
    • VBA Else If
  • Excel Functions (10+)
  • Excel Tools (97+)
  • Financial Functions in Excel (17+)
  • Logical Functions in Excel (12+)
  • Lookup Reference Functions in Excel (30+)
  • Maths Function in Excel (39+)
  • TEXT and String Functions in Excel (25+)
  • Date and Time Function in Excel (20+)
  • Statistical Functions in Excel (55+)
  • Information Functions in Excel (4+)
  • Excel Charts (44+)
  • Excel Tips (195+)
  • Workplace Productivity (4+)
  • Microsoft Office Tools (14+)
  • Excel Formula and Functions (20+)
  • MS Excel Shortcuts (4+)
Excel Functions Courses
  • VBA Training
  • Excel Advanced Training
  • Excel Data Analysis Training
Footer
About Us
  • Who is EDUCBA?
  • Sign Up
  •  
Free Courses
  • Free Online Excel Course
  • Free Vba Course
Certification Courses
  • All Courses
  • Excel VBA Course - All in One Bundle
  • VBA Course
  • Excel Data Analysis Course
  • Excel for Marketing Course
  • Excel for Finance Course
  • Excel for HR Training
Resources
  • Resources (A To Z)
  • Excel Charts
  • Excel Tips
  • Excel Tools in Excel
  • Excel Functions
  • Financial Functions in Excel
  • Logical Functions in Excel
  • Lookup Reference Functions in Excel
  • Maths Function in Excel
  • TEXT and String Functions in Excel
  • Date and Time Function in Excel
  • Statistical Functions in Excel
  • Information Functions in Excel
Apps
  • iPhone & iPad
  • Android
Support
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions

© 2019 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

Download VBA Font Color Excel Template

By continuing above step, you agree to our Terms of Use and Privacy Policy.
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Let’s Get Started
Please provide your Email ID
Email ID is incorrect