Results 1 to 6 of 6

changing userform label control's color dynamically

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-02-2005
    Posts
    100

    changing userform label control's color dynamically

    edit - file test.xlsm attached

    I'm trying to change label text colors dynamically in a user form based on the value of a checkbox.

    Objects:

    checkbox: chkTest
    label: lblTest
    textbox: txtTest

    I set label's forecolor in the control's property to red (H000000FF) then run the following code:

    Private Sub chkTest_Change()
    
    If chkTest.Value = True Then
        lblTest.ForeColor = H0000FF00 'should change text to green if true
        txtTest.Value = "On - Green"
        
    ElseIf chkTest.Value = False Then
        lblTest.ForeColor = H00FF0000 'should change text to blue if false
        txtTest.Value = "Off - Blue"
    End If
    
    End Sub
    On initialization of the form, the label's text is properly red.

    But on chkbox click, the text turns black once and never changes again. The txtbox updates its value properly.

    What am I doing wrong?

    What I want to do is have a large section of one of my userforms to activate and change color if a particular checkbox is true. If False, then the controls are disabled and are greyed out.

    Thanks!
    Last edited by Ouka; 09-30-2014 at 02:30 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 05-22-2013, 10:24 PM
  2. VBA User Form Label won't show
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2011, 09:57 AM
  3. Sorting Button (form control) alphabetically based on text label
    By DTK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2010, 08:48 PM
  4. Filling form fields via worksheet dropdowns, user update via form, change form color
    By Demosthenes&Locke in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2010, 08:58 AM
  5. In need to format a label in an user form
    By jobro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2008, 08:07 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1