Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9235195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:58:10+00:00 2026-06-18T06:58:10+00:00

I have a userform in Excel 2003 which contains some MSForms.Label controls. I want

  • 0

I have a userform in Excel 2003 which contains some MSForms.Label controls. I want to set the .BackColor property of each of these controls such that they match the color of some individual cells on a worksheet.

To do this I am reading the .Interior.Color property of those cells, converting it to hex and using that value to set the .BackColor property of the Label objects.

My problem is that the value coming out of .Interior.Color is almost always incorrect the first time it is read. I have tested this by running the following command in the VBA editor immediate window:

Print Hex([sourceCell].Interior.Color)

This command almost always gives the wrong value the first time round, but gives the correct value from the second time onwards. If I change the fill color of [sourceCell] and run the command again it will do the same thing, i.e. wrong value first time, right value second time onwards.

The cells in question are all filled with colors from the chart lines/fills color selection (i.e. the two bottom rows you can see in Excel’s “Format Cells” dialog under the “Patterns” tab). These colors have been modified by me to give a custom set of colors and, tellingly, the “wrong” values seem to match Excel’s defaults for the customized range of color picks (i.e. the default chart line/fill colors you get when you start a new workbook).

Has anyone else experienced this behaviour/have a workaround? When I try to read the values twice at runtime it doesn’t work, i.e. it doesn’t switch to the correct value. The code must be stopped and the userform reloaded to force the “correct” values to come out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:58:11+00:00Added an answer on June 18, 2026 at 6:58 am

    Kludge/workaround via Application.OnTime.

    If I run the userform prep code to set the label objects’ backcolors with the userform hidden, then set the main code to run from an immediate OnTime event (making sure to re-run the prep code as part of the OnTime) then I can force Excel to give me the correct “second time round” values when showing the form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In excel vba I have added a commandbutton to userform... like below Set ctrl
I have userform which collects some user input. Now what I'm trying to do,
I currently have built a tool in Excel 2003 which displays a series of
I have an Excel form which reads data from each row of an 80-row
I am new to VBA in Excel, and I have a basic userform which
I currently have a excel document which is managed by different userforms. I want
I have a UserForm class which has a select list populated from a related
I have developed an UserForm VBA module. But i want that userform when opening
I have a TreeView in excel 2007 with checkboxes. I want the checkboxes to
I have a UserForm with some textbox entry fields on it that are enabled/disabled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.