Results 1 to 10 of 10

Thread: [RESOLVED] [Excel] Interior Colours (or colors)

  1. #1

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Resolved [RESOLVED] [Excel] Interior Colours (or colors)

    Hi,

    In Excel it says you can change the colour using the rgb function and setting the interior colour to that.

    This seems to work. Well no it doesn't. This gets your colour and matches it to the nearest index.

    Is it possible to show colours not in the index list?
    If so - how?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [Excel] Interior Colours (or colors)

    I remember reading a thread before about a similar isue. I think it was found that only the colorindex would work as certain rgb values didnt make color changes but some did, just not all.

    Try a search for the thread here in OD for more info on it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: [Excel] Interior Colours (or colors)

    Found your previous post - seems to be limited now (I think I recall a v97 working with custom colours, but nothing like that now).

    Thanks for your help.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: [RESOLVED] [Excel] Interior Colours (or colors)

    Vince ... here is the post: [RESOLVED] EXCEL: ? Range of Cell Fill Colors

    Here is a little demo to display all of the possible valid indices and their colors:
    Code:
    Option Explicit
    'Display your COLOR PALETTE
    Sub Macro1()
    Dim i As Integer
    Dim jRow As Integer
    
    'Start at the first row
    jRow = 1
    
    'This is a funny Color Index, but it works!
    i = -4142
    'Load the funny color
    Cells(jRow, "A").Value = i
    Cells(jRow, "B").Interior.ColorIndex = i
    
    'Walk down the sheet putting the index in A and coloring B
    For i = 0 To 57
        jRow = jRow + 1
        On Error GoTo ERROR_COLOR_INDEX
            Cells(jRow, "A").Value = i
            Cells(jRow, "B").Interior.ColorIndex = i
        On Error GoTo 0
    Next i
    Exit Sub
    '
    ERROR_COLOR_INDEX:
        Cells(jRow, "A").Value = i
        Cells(jRow, "B").Value = "END"
        End
        
    End Sub
    I learned just today that the Visual Basic Editor/Debugger can actually change your color palette! My assistant thought he was going crazy because cells that have been 'Light Turquoise' for ages suddenly changed color and several color names changed to "color scheme". When he closed Excel and then reopened it, the colors reverted to their 'traditional' hues.
    Last edited by Webtest; May 23rd, 2006 at 02:57 PM.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] [Excel] Interior Colours (or colors)

    Yes, thats the thread.

    Nice .colorindex code Art
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] [Excel] Interior Colours (or colors)

    I just noticed that I dont get a color for "-4142" what color is it supossed to be?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: [RESOLVED] [Excel] Interior Colours (or colors)

    Do: "MsgBox Range("A1").Interior.ColorIndex" on a newly created sheet ... "No Fill" ... seems to be exactly the same as ColorIndex = 0!
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  8. #8
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: [RESOLVED] [Excel] Interior Colours (or colors)

    In fact, if you set a cell ColorIndex to 0 in code and then immediately read it back in the next line, you'll see the "-4142" and not the 0!
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  9. #9

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: [RESOLVED] [Excel] Interior Colours (or colors)

    Cheers. That was the thread I found.

    Doesn't seem to be a point in giving vba coders the choice of putting a custom colour into the cells background then automatching to an indexed colour. Another great idea from MS...

    The code to loop through the indexes is great. I think I wrote something like it that displayed the colours on a sheet, but it was about a year ago. Probably lost the code somewhere

    Thanks for your help

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  10. #10
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: [RESOLVED] [Excel] Interior Colours (or colors)

    Vince ...

    Any time my assistant or I does a short routine to test or proof something, we put it in a special "Cookbook" folder on our shared "Teamwork" drive. There are about 25 examples right now ... that's how I came up with the Color Chart so quickly. That's about my only claim to 'organizational skills'.

    What is really nasty about the Palette system is that there are some VERY useful colors (Extra Light Yellow) that can ONLY be set programmatically! There are only 41 of the available color selections on the "Fill Color" Tool. Yuk!
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

Posting Permissions

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



Click Here to Expand Forum to Full Width