+ Reply to Thread
Results 1 to 6 of 6

Loop to demonstrate all System BackColors?

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Question Loop to demonstrate all System BackColors?

    Slightly unusual request. (It's an experiment to help me solve another thread)

    I want a loop which will go through all the possible System colors that can be set as a .BackColor.

    For each System Color, add a control to Form1 (any control - command button would probably be the best display-wise)

    also- if possible - name the control caption to display the name of the system color (and/or hex value)


    I'd write this myself but IDK if it is possible to loop through colors available on Form controls. Is it?
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Loop to demonstrate all System BackColors?

    Well, if you consider that each of the 3 RGB components can range from 1 to 255, that would give you 16,581,375 possible colors. Care to proceed
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Loop to demonstrate all System BackColors?

    Quote Originally Posted by natefarm View Post
    Well, if you consider that each of the 3 RGB components can range from 1 to 255, that would give you 16,581,375 possible colors. Care to proceed
    Nope. I'm only after the System colors - there only appears to be about 30 or so in the list... (Create a new form, add a Command Button, properties, .backcolor, choose System, scroll list)

  4. #4
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Loop to demonstrate all System BackColors?

    I see what you're after, but couldn't find anything on the internet indicating that VBA has named constants for those colors. It looks like there are only 8-10 different colors, and the rest are redundant or so close that I can't tell the difference. Sorry, but I'm not seeing an automatic way to get what you want.

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Loop to demonstrate all System BackColors?

    Quote Originally Posted by natefarm View Post
    I see what you're after, but couldn't find anything on the internet indicating that VBA has named constants for those colors
    Well it's all new to me but I've found that VBA does have named constants for these colours, I've worked out a few of their names e.g. vbScrollBars = the Scroll Bars color. That one was easy. But some of the other system colors reject this logic.

    If I had list of all these named constants then I could place their name strings in an array for looping.

  6. #6
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Loop to demonstrate all System BackColors?

    MS had the details http://msdn.microsoft.com/en-us/libr...(v=vs.60).aspx

    Then all I had to do was write the code to add the buttons with the backcolors.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Loop to Sym and Average values by System
    By trizzo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-18-2013, 02:16 PM
  2. Do Loop/Function/VB/Macro to automate system description ID entry
    By ShagNasty in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-02-2012, 04:35 PM
  3. [SOLVED] Hide/Unhide worksheets that are dependant on cell value (loop system)
    By papasideris in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-27-2012, 07:29 AM
  4. loop system for hiding and unhidding worksheets
    By papasideris in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-24-2012, 10:49 AM
  5. Chart to demonstrate
    By seanyeap in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 11-05-2008, 10:21 AM

Tags for this Thread

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