+ Reply to Thread
Results 1 to 4 of 4

Combobox User Form - Select 1 of Excels 56 Colours - Build Array from Colour Index

  1. #1
    Registered User
    Join Date
    07-09-2015
    Location
    Toronto
    MS-Off Ver
    Excel 2013
    Posts
    2

    Combobox User Form - Select 1 of Excels 56 Colours - Build Array from Colour Index

    Hi,
    First Post for me.

    Thanks to all of you folks who check these forms and help out. I'm a student learning VBA and programming for the first time, the hair pulling and stress becomes quite fun after a few weeks, but if it wasn't for these forums it wouldn't, it would suck, a lot.

    I am stuck, not looking for the answer just the direction.

    Everyone know the game DOTS? I am building this in VBA, one of my userforms has a combo box where players can select the board colours for the game.

    I want to populate this list with the 56 colours of the excel colour index. How does excel store the values in the colour index, is it as an array, is the array two dimensional or how does excel convert the Names of the colour index to numbers (like black = 1, the colorindex = 1 and somehwere excel has it written that 1 is black...where is this rainbow?)

    I thought maybe I'd be lucky and the code would something like:
    ' In Module build array:
    ' option base 1 is on
    Please Login or Register  to view this content.
    and then in the userform
    userform_initialize()

    Please Login or Register  to view this content.
    Logically, I can see several flaws (like what would the combobox be populated with, number 1 to 56, names etc...)

    I've searched many forums and many posts about the colorIndex but they are too basic for even this basic question.

    Thanks for reading, feedback, hints, etc... are welcome, please do not post the solution code though, I can't learn from copying as well as I can learn from problem solving...just looking for a hint or well to know if my plan is even possible.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Combobox User Form - Select 1 of Excels 56 Colours - Build Array from Colour Index

    hi ecade welcome to the forum
    Firstly, in the first code, you have a for loop. In it you assign the colorindex(i) to an array but not sure it is necessary since you could, in the initialize form just loop through colorindex instead of the array you build? If you do want to populate the array, then ColorIndex probably should not have a "." in front, since the . would mean the colorindex of something (and I don't see a "with", not just the colorindex(i). I'm also not sure it is possible at all since colorindex is a property, not a "value" as such.
    Last edited by Arkadi; 07-09-2015 at 09:28 AM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Combobox User Form - Select 1 of Excels 56 Colours - Build Array from Colour Index

    I would use a different approach.
    Rather than the user picking a ColorIndex, I would assign each game element its own color index and let the user change the color that that index represents.

    Note that Workbook.Colors(i) returns the RGB value of ColorIndex i.
    The value of Colors(i) can be changed either with hard-coded values or with the Application.Dialog(xlDialogEditColors)

    In the attached user form, Label1 is always ColorIndex 51 (although the user can change what color 51 represents). Label2 is ColorIndex 52. The Firmset Color button sets those indexes to predetermined colors (in this case red and blue).

    Please Login or Register  to view this content.
    Attached Files Attached Files
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    07-09-2015
    Location
    Toronto
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Combobox User Form - Select 1 of Excels 56 Colours - Build Array from Colour Index

    Thanks Arkadi for the reply, I have played around for a bit and I think you are right and won't work in this way. Its ok, luckily the wheel has been designed I just need to understand how to refit it my tires.

+ 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. Please help with input form, arrays and a function
    By jbaich in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-20-2014, 01:50 PM
  2. [SOLVED] User-Form Problem: User can select headers in User Form (I want Header/no way to select)
    By navialivad in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2014, 10:24 AM
  3. Transfer User form data to a worksheet w.r.t. combobox item on the form
    By nm766 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2011, 12:43 PM
  4. transferring combobox value from one user form to populate combobox on another
    By smartphreak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2010, 10:12 PM
  5. Replies: 1
    Last Post: 05-10-2006, 07:30 PM

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