Results 1 to 11 of 11

Thread: [RESOLVED] EXCEL: ? Range of Cell Fill Colors

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Resolved [RESOLVED] EXCEL: ? Range of Cell Fill Colors

    Esteemed Forum Participants and Lurkers:
    ===============================
    Excel 2003 VBA

    As near as I can tell, the range of Fill Colors for Cells is from 0 to 56, and -4142. Is this all I get? No custom color fill?

    By the way, here is a macro to build a map of Color Index values in Column A, and Column B filled with that color. Run it on a blank sheet:
    Code:
    Option Explicit
    'Display your COLOR PALLETTE
    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
    Last edited by Webtest; Feb 23rd, 2006 at 08:15 AM.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  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: ? Range of Fill Colors ???

    Instead of the .ColorIndex property use the .Color property with an RGB color value.
    VB Code:
    1. .Color = RGB(0, 255, 0)
    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
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: EXCEL: ? Range of Fill Colors ???

    u are just full of info today!! writing that one down as well LOL

    I need to give some reps to others so I can hit u again!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4
    Lively Member
    Join Date
    Jun 2005
    Posts
    112

    Re: EXCEL: ? Range of Fill Colors ???

    Today? Rob has made me change my underwear more often than my washing machine can handle.

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

    Re: EXCEL: ? Range of Fill Colors ???

    Thanks guys. Its always nice to hear positive feedback for all my efforts. I have been side tracked for the past couple of months and now getting ready to get back deep into programming so be warned and make sure your wearing some Depends for protection.
    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
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: EXCEL: ? Range of Fill Colors ???

    Incidentally, I listed all the colours in an Enum here...

    Also, you can use the Pattern property to give it stripes or a grid.


    zaza

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: EXCEL: ? Range of Fill Colors ???

    Quote Originally Posted by RobDog888
    Instead of the .ColorIndex property use the .Color property with an RGB color value.
    VB Code:
    1. .Color = RGB(0, 255, 0)
    Thanks for the tip RobDog, but it is an "Optical Delusion". I was playing with light gray, but the lightest gray I can get is "aCell.Interior.Color = RGB(223, 223, 223)". When I increment to "(224, 224, 224)" the cell goes from medium gray to white, and of course is white for all values from 224 through 255.

    I settled on a light yellow (ColorIndex = 19) that results in a fairly pale gray on a B&W laser printer. Reading back the Color for a cell at ColorIndex = 19 yields an RGB value of (255, 255, 204). Changing the Blue value from 204 to 229 does nothing. It switches to White from 230 to 255. So, we are essentially still stuck with the ColorIndex pallette for cell fill, but thanks for the insight.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

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

    Re: [RESOLVED] EXCEL: ? Range of Cell Fill Colors

    Shouldnt it be an "Optical Illusion" ? I didnt test it with such a detailed color range so thanks for letting us know its limitation.
    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

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

    Re: [RESOLVED] EXCEL: ? Range of Cell Fill Colors

    Oh I just remembered that when I was creating custom labels for appointments in Outlook there were only certain colors that would display in terminal server because of a 256 color depth desktop. Are you running True color color depth?
    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

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: [RESOLVED] EXCEL: ? Range of Cell Fill Colors

    RobDog ...

    The quotes are significant ... "Optical Delusion" ... Thinking you're getting something really neat visually, but not quite ...

    I was going to mention it but forgot ... (Senior Moment) ...
    Display Properties > Settings > Display > Colors > True Color (32 bit)

    We are definitely limited to a pallette for Cell Fill.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

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

    Re: [RESOLVED] EXCEL: ? Range of Cell Fill Colors

    Yes, graphics are limited in all of VBA. No picturebox control, no drawing on a userform, etc.
    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

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