• Login
  • Courses
  • Books
  • Cheat Sheets
  • Tutorials Archive
  • VBA Code Generator
  • Contact

Power Spreadsheets

Excel and VBA tutorials and training. Learn how to use Microsoft Excel and Visual Basic for Applications now.

Excel VBA UserForm Label Font Color in 2 Easy Steps (+ Free Easy-To-Adjust Excel Workbook Example)

Excel VBA UserForm Label Font Color in 2 Easy Steps (+ Free Easy-To-Adjust Excel Workbook Example)In this Excel VBA UserForm Label Font Color Tutorial, you learn how to change an ActiveX Label's font color with Excel macros (when the ActiveX Label is in a UserForm).

This Excel VBA UserForm Label Font Color Tutorial:

  • Applies to Labels in a UserForm. These are the Labels you insert (for example) through the Visual Basic Editor's (VBE's) Toolbox.
  • Doesn't apply to the following:
    • ActiveX Labels in a worksheet.
      • These are the Labels you insert (for example) through the Insert dropdown in the Developer tab of the Ribbon.
    • Chart labels.

This Excel VBA UserForm Label Font Color Tutorial is accompanied by an Excel workbook with the data and VBA code I use when describing the step-by-step process below. Get this example workbook (for free) by clicking the button below.


Get immediate free access to the Excel VBA UserForm Label Font Color workbook example

The VBA code in the Excel workbook that accompanies this Excel VBA UserForm Label Font Color Tutorial is (always) stored in the Visual Basic Editor (VBE). If you don't know how to work with the VBE, I suggest you read my Visual Basic Editor (VBE) Tutorial. I link to this Tutorial in the Related Excel Macro and VBA Training Materials and Resources Section below.

Table of Contents

  • Related Excel Macro and VBA Training Materials and Resources
  • The VBA UserForm Label Font Color Snippet Template/Structure
  • The Example Before VBA UserForm Label Font Color
  • Step 1: Refer to UserForm Label
    • Step 1 Example
  • Step 2: Set the Value of the ForeColor Property
    • Step 2 Example
  • Download the VBA UserForm Label Font Color Example Workbook
  • Related Excel Macro and VBA Training Materials and Resources

Related Excel Macro and VBA Training Materials and Resources

The following Excel Macro and VBA Tutorials may help you better understand and implement the contents below.

  • Tutorials about general macro and VBA constructs and structures:
    • Tutorials for Beginners:
      • Excel Macros: Click here to open.
      • Excel VBA: Click here to open.
    • Enable macros in Excel: Click here to open.
    • Work with the Visual Basic Editor (VBE): Click here to open.
    • Create Sub procedures: Click here to open.
    • Refer to objects: Click here to open.
    • Work with:
      • Properties: Click here to open.
      • Data types: Click here to open.
      • Functions: Click here to open.
      • The Select Case statement: Click here to open.
      • Events: Click here to open.
  • Tutorials with practical VBA applications and macro examples:
    • Work with the Value property: Click here to open.
    • Work with font characteristics: Click here to open.
    • Create UserForms: Click here to open.

This Excel VBA UserForm Label Font Color Tutorial is part of a more comprehensive series of Excel VBA Font Color Tutorials.

  • Excel VBA Font Color Index in 2 Easy Steps: Click here to open.
  • Excel VBA Font Color RGB in 2 Easy Steps: Click here to open.
  • Excel VBA Font Color HEX in 5 Easy Steps: Click here to open.
  • Excel VBA Change Font Color Based on Cell Value in 4 Easy Steps: Click here to open.
  • Excel VBA Change Font Color for Part of Text in 8 Easy Steps: Click here to open.
  • Excel VBA Text Box Font Color in 2 Easy Steps: Click here to open.
  • Excel VBA ActiveX Text Box Font Color in 2 Easy Steps: Click here to open.
  • Excel VBA UserForm Text Box Font Color in 2 Easy Steps: Click here to open.
  • Excel VBA Chart Data Label Font Color in 4 Easy Steps: Click here to open.
  • Excel VBA ActiveX Label Font Color in 2 Easy Steps: Click here to open.

You can find more Excel and VBA Tutorials in the organized Tutorials Archive: Click here to visit the Archives.

If you want to learn how to automate Excel (and save time) by working with macros and VBA, you may be interested in the following Premium Excel Macro and VBA Training Materials:

  • Premium Courses at the Power Spreadsheets Academy: Click here to open.
  • Books at the Power Spreadsheets Library: Click here to open.
  • VBA Cheat Sheets: Click here to open.

If you want to save time when working with macros and VBA, you may be interested in AutoMacro: Click here to learn more about AutoMacro (affiliate link). AutoMacro is an add-in for VBA that installs directly into the VBE. Depending on the version, AutoMacro comes loaded with:

  • Code generators.
  • An extensive code library.
  • The ability to create your own code library.
  • Advanced coding tools.

If you need consulting services, you may want to consider working with ExcelRescue. ExcelRescue is my usual suggestion for people who (like you) may need help with Excel tasks/projects: Click here to visit ExcelRescue (affiliate link).


Get immediate free access to the Excel VBA UserForm Label Font Color workbook example

The VBA UserForm Label Font Color Snippet Template/Structure

The following is the VBA UserForm label font color snippet template/structure I explain (step-by-step) in the Sections below.

'Source: https://powerspreadsheets.com/
'More information: https://powerspreadsheets.com/vba-label-font-color/
UserFormObjectReference.LabelControlCodeName.ForeColor = NewForeColorValue


Get immediate free access to the Excel VBA UserForm Label Font Color workbook example

The Example Before VBA UserForm Label Font Color

This Excel VBA UserForm Label Font Color Tutorial is accompanied by an Excel workbook with the data and VBA code I use when describing the step-by-step process below. Get this example workbook (for free) by clicking the button below.


Get immediate free access to the Excel VBA UserForm Label Font Color workbook example

The VBA code in the Excel workbook that accompanies this Excel VBA UserForm Label Font Color Tutorial is (always) stored in the Visual Basic Editor (VBE). If you don't know how to work with the VBE, I suggest you read my Visual Basic Editor (VBE) Tutorial. I link to this Tutorial in the Related Excel Macro and VBA Training Materials and Resources Section above.

The example workbook has a UserForm with 2 controls:

  • A Label.
    • This is the UserForm Label the VBA UserForm Label font color example macro I create (by following the step-by-step process below) works with. In other words: This is the UserForm Label where the example macro (when executed) sets the font color.
  • A Text Box.
    • The VBA UserForm Label font color example macro I create (by following the step-by-step process below) sets the UserForm Label font color depending on the string in this UserForm Text Box.
Example Excel UserForm for VBA Label font color example macro


Get immediate free access to the Excel VBA UserForm Label Font Color workbook example

Step 1: Refer to UserForm Label

Refer to the UserForm Label whose font color you want to set.

In other words: Create a VBA expression that returns an ActiveX Label control (object) representing the UserForm Label whose font color you want to set.

Consider doing the following when referring to the UserForm Label you work with:

  • Store the procedure setting the UserForm Label font color inside the applicable UserForm class module.
  • Use:
    • The Me keyword to refer to the applicable UserForm.
    • The Label's codename to refer to the applicable Label control (object) inside the applicable UserForm.
  • Find (and change) the Text Box's codename ((Name) property) in the applicable Properties Window.
Specify UserForm Label codename

The basic expression structure/template to refer to the UserForm Label is as follows:

'Source: https://powerspreadsheets.com/
'More information: https://powerspreadsheets.com/vba-label-font-color/
UserFormObjectReference.LabelControlCodeName


Get immediate free access to the Excel VBA UserForm Label Font Color workbook example

Step 1 Example

I:

  • Store the example procedure (setting the UserForm Label font color) inside the applicable UserForm class module.
  • Work with a With… End With block. The statements inside the With… End With block work with the UserForm.
  • Refer to the Label codenamed “UserFormLabelFontColor” inside the UserForm.
  • Work with the following VBA constructs to obtain an ActiveX Label control (object) representing this UserForm Label:
    • The Me keyword: Me.
    • The ActiveX Label's codename: UserFormLabelFontColor.
'Source: https://powerspreadsheets.com/
'More information: https://powerspreadsheets.com/vba-label-font-color/
With Me
    .UserFormLabelFontColor
End With


Get immediate free access to the Excel VBA UserForm Label Font Color workbook example

Step 2: Set the Value of the ForeColor Property

Do the following to set the applicable ActiveX Label's font color with the ForeColor property:

(1) Start with the ActiveX Label control (object) reference you created in step #1:

'Source: https://powerspreadsheets.com/
'More information: https://powerspreadsheets.com/vba-label-font-color/
UserFormObjectReference.LabelControlCodeName

(2) Refer to the ForeColor property.

'Source: https://powerspreadsheets.com/
'More information: https://powerspreadsheets.com/vba-label-font-color/
UserFormObjectReference.LabelControlCodeName.ForeColor

(3) Set the value of the ForeColor property.

The ForeColor property specifies the UserForm Label's font color as a value of the Long data type representing the applicable red, green, and blue components.

  • Consider working with the RGB function to set the value of the of the ForeColor property by specifying the applicable red, green, and blue components.
  • If you don't know how to work with the RGB function, I suggest you read my Excel VBA Font Color RGB Tutorial I link to in the Related Excel Macro and VBA Training Materials and Resources Section above.

You can (also) consider setting the ForeColor property to:

  • Any of VBA's color constants:
    • vbBlack.
    • vbRed.
    • vbGreen.
    • vbYellow.
    • vbBlue.
    • vbMagenta.
    • vbCyan.
    • vbWhite.
  • Any of VBA's system color constants:
    • vbScrollBars: Scroll bar color.
    • vbDesktop: Desktop color.
    • vbActiveTitleBar: Color of the active window's title bar.
    • vbInactiveTitleBar: Color of an inactive window's title bar.
    • vbMenuBar: Menu background color.
    • vbWindowBackground: Window background color.
    • vbWindowFrame: Window frame color.
    • vbMenuText: Color text in menus.
    • vbWindowText: Color text in windows.
    • vbTitleBarText: Color text in caption, size box, and scroll arrow.
    • vbActiveBorder: Active window's border color.
    • vbInactiveBorder: Inactive window's border color.
    • vbApplicationWorkspace: Background color of multiple document interface applications.
    • vbHighlight: Background color of items selected in a control.
    • vbHighlightText: Text color of items selected in a control.
    • vbButtonFace: Shading color on the face of command buttons.
    • vbButtonShadow: Shading color on the edge of command buttons.
    • vbGrayText: Disabled (greyed out) text.
    • vbButtonText: Push button text color.
    • vbInactiveCaptionText: Text color in inactive caption.
    • vb3DHighlight: Highlight color for 3-D display elements (Button Highlight).
    • vb3DDKShadow: Darkest shadow color for 3-D display elements (Button Dark Shadow).
    • vb3DLight: Second lightest 3-D color (after vb3DHighlight; Button Light Shadow).
    • vbInfoText: Tooltip text color.
    • vbInfoBackground: Tooltip background color.
'Source: https://powerspreadsheets.com/
'More information: https://powerspreadsheets.com/vba-label-font-color/
UserFormObjectReference.LabelControlCodeName.ForeColor = NewForeColorValue


Get immediate free access to the Excel VBA UserForm Label Font Color workbook example

Step 2 Example

I do the following to set the value of the ForeColor property:

(1) Work with an event handler procedure triggered by the Change event of the TextBox control (object). The Change event occurs when the Value property of the TextBox control (object) changes.

The codename of the Text Box control I refer to is “UserFormTextBoxFontColor”

'Source: https://powerspreadsheets.com/
'More information: https://powerspreadsheets.com/vba-label-font-color/
Private Sub UserFormTextBoxFontColor_Change()
    With Me
        .UserFormLabelFontColor
    End With
End Sub

(2) Work with the If… Then… Else statement to do the following:

  • Test whether the text in the Text Box's edit region is “Excel VBA UserForm Label Font Color”.
  • Specify the value of the ForeColor property of the Label control (object):
    • One way (if the tested condition is met); or
    • Another way (if the tested condition isn't met).
'Source: https://powerspreadsheets.com/
'More information: https://powerspreadsheets.com/vba-label-font-color/
Private Sub UserFormTextBoxFontColor_Change()
    With Me
        If .UserFormTextBoxFontColor.Value = "Excel VBA UserForm Label Font Color" Then
            .UserFormLabelFontColor
        Else
            .UserFormLabelFontColor
        End If
    End With
End Sub

If the text in the Text Box's edit region is “Excel VBA UserForm Label Font Color”, I use the RGB function to set the value of the ForeColor property of the Label control (ForeColor = RGB(0, 128, 55)). I specify the Red, Green, and Blue arguments of the RGB function as follows:

  • Red: 0.
  • Green: 128.
  • Blue: 55.
'Source: https://powerspreadsheets.com/
'More information: https://powerspreadsheets.com/vba-label-font-color/
Private Sub UserFormTextBoxFontColor_Change()
    With Me
        If .UserFormTextBoxFontColor.Value = "Excel VBA UserForm Label Font Color" Then
            .UserFormLabelFontColor.ForeColor = RGB(0, 128, 55)
        Else
            .UserFormLabelFontColor
        End If
    End With
End Sub

If the text in the Text Box's edit region isn't “Excel VBA UserForm Label Font Color”, I set the value of the ForeColor property of the Label control to VBA's vbBlack color constant (ForeColor = vbBlack).

'Source: https://powerspreadsheets.com/
'More information: https://powerspreadsheets.com/vba-label-font-color/
Private Sub UserFormTextBoxFontColor_Change()
    With Me
        If .UserFormTextBoxFontColor.Value = "Excel VBA UserForm Label Font Color" Then
            .UserFormLabelFontColor.ForeColor = RGB(0, 128, 55)
        Else
            .UserFormLabelFontColor.ForeColor = vbBlack
        End If
    End With
End Sub

The full VBA UserForm Label font color example macro is as follows:

Private Sub UserFormTextBoxFontColor_Change()
    'Source: https://powerspreadsheets.com/
    'More information: https://powerspreadsheets.com/vba-label-font-color/
    
    'Step 1: Refer to this UserForm
    With Me
        
        'Do the following:
            '(1) Test whether the UserFormTextBoxFontColor Text Box in this UserForm contains "Excel VBA UserForm Label Font Color"
            '(2) Set the value of the ForeColor property of the UserFormLabelFontColor Label in this UserForm depending on whether (or not) the UserFormTextBoxFontColor Text Box contains "Excel VBA UserForm Label Font Color"
        If .UserFormTextBoxFontColor.Value = "Excel VBA UserForm Label Font Color" Then

            'Step 2 (option 1): Use the RGB function to set the value of the ForeColor property of the UserFormLabelFontColor Label. Specify the red, green, and blue components of the color as follows:
                'Red: 0
                'Green: 128
                'Blue: 55
            .UserFormLabelFontColor.ForeColor = RGB(0, 128, 55)
        Else

            'Step 2 (option 2): Set the value of the ForeColor property of the UserFormLabelFontColor Label to VBA's vbBlack color constant
            .UserFormLabelFontColor.ForeColor = vbBlack
        End If
    End With

End Sub

The following GIF illustrates the effects of executing the VBA UserForm Label font color example macro (when the Change event of the TextBox control occurs).

Excel VBA UserForm Label font color example


Get immediate free access to the Excel VBA UserForm Label Font Color workbook example

Download the VBA UserForm Label Font Color Example Workbook

This Excel VBA UserForm Label Font Color Tutorial is accompanied by an Excel workbook with the data and VBA code I use when describing the step-by-step process above. Get this example workbook (for free) by clicking the button below.


Get immediate free access to the Excel VBA UserForm Label Font Color workbook example

The VBA code in the Excel workbook that accompanies this Excel VBA UserForm Label Font Color Tutorial is (always) stored in the Visual Basic Editor (VBE). If you don't know how to work with the VBE, I suggest you read my Visual Basic Editor (VBE) Tutorial. I link to this Tutorial in the Related Excel Macro and VBA Training Materials and Resources Section above.

Related Excel Macro and VBA Training Materials and Resources

The following Excel Macro and VBA Tutorials may help you better understand and implement the contents above.

  • Tutorials about general macro and VBA constructs and structures:
    • Tutorials for Beginners:
      • Excel Macros: Click here to open.
      • Excel VBA: Click here to open.
    • Enable macros in Excel: Click here to open.
    • Work with the Visual Basic Editor (VBE): Click here to open.
    • Create Sub procedures: Click here to open.
    • Refer to objects: Click here to open.
    • Work with:
      • Properties: Click here to open.
      • Data types: Click here to open.
      • Functions: Click here to open.
      • The Select Case statement: Click here to open.
      • Events: Click here to open.
  • Tutorials with practical VBA applications and macro examples:
    • Work with the Value property: Click here to open.
    • Work with font characteristics: Click here to open.
    • Create UserForms: Click here to open.

This Excel VBA UserForm Label Font Color Tutorial is part of a more comprehensive series of Excel VBA Font Color Tutorials.

  • Excel VBA Font Color Index in 2 Easy Steps: Click here to open.
  • Excel VBA Font Color RGB in 2 Easy Steps: Click here to open.
  • Excel VBA Font Color HEX in 5 Easy Steps: Click here to open.
  • Excel VBA Change Font Color Based on Cell Value in 4 Easy Steps: Click here to open.
  • Excel VBA Change Font Color for Part of Text in 8 Easy Steps: Click here to open.
  • Excel VBA Text Box Font Color in 2 Easy Steps: Click here to open.
  • Excel VBA ActiveX Text Box Font Color in 2 Easy Steps: Click here to open.
  • Excel VBA UserForm Text Box Font Color in 2 Easy Steps: Click here to open.
  • Excel VBA Chart Data Label Font Color in 4 Easy Steps: Click here to open.
  • Excel VBA ActiveX Label Font Color in 2 Easy Steps: Click here to open.

You can find more Excel and VBA Tutorials in the organized Tutorials Archive: Click here to visit the Archives.

If you want to learn how to automate Excel (and save time) by working with macros and VBA, you may be interested in the following Premium Excel Macro and VBA Training Materials:

  • Premium Courses at the Power Spreadsheets Academy: Click here to open.
  • Books at the Power Spreadsheets Library: Click here to open.
  • VBA Cheat Sheets: Click here to open.

If you want to save time when working with macros and VBA, you may be interested in AutoMacro: Click here to learn more about AutoMacro (affiliate link). AutoMacro is an add-in for VBA that installs directly into the VBE. Depending on the version, AutoMacro comes loaded with:

  • Code generators.
  • An extensive code library.
  • The ability to create your own code library.
  • Advanced coding tools.

If you need consulting services, you may want to consider working with ExcelRescue. ExcelRescue is my usual suggestion for people who (like you) may need help with Excel tasks/projects: Click here to visit ExcelRescue (affiliate link).

guest
guest
1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

I publish a lot of Tutorials and Training Resources about Microsoft Excel and VBA. Here are some of my most popular Excel Training Resources:

  1. Free Excel VBA Email Course
  2. Excel Macro Tutorial for Beginners
  3. Excel Power Query (Get and Transform) Tutorial for Beginners
  4. Excel Keyboard Shortcut Cheat Sheet
  5. Excel Resources
Terms and Conditions

Privacy Policy

Limit of Liability and Disclaimer of Warranty

Affiliate Disclosure

Copyright © 2015–2023 PDS Intelligence Pte. Ltd. All rights reserved.
Excel ® is a registered trademark of the Microsoft Corporation. Power Spreadsheets is not affiliated with the Microsoft Corporation.