Results 1 to 3 of 3

finding color codes for setting background colors in vba

Threaded View

pongmeister finding color codes for... 02-25-2018, 10:17 PM
kersplash Re: finding color codes for... 02-25-2018, 10:35 PM
pongmeister Re: finding color codes for... 02-26-2018, 12:32 AM
  1. #1
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    314

    finding color codes for setting background colors in vba

    I need to set cell background colors in vba. I've got a lot of variables that makes it cumbersome to use conditional formatting. I need some help in understanding the color codes.

    I used the macro recorder to see how a background color is set. I chose a bright yellow color and the macro came back with a color code:

        Range("G7").Select
        With Selection.Font
            .Name = "Tahoma"
            .FontStyle = "Regular"
            .Size = 10
            .Strikethrough = False
            .Superscript = True
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorDark1
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 5296274
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
    End Sub
    As you can see the color code shows 5296274 and I don't see that type number anywhere I've looked. How can I find the correct codes to use in setting other cells and other colors?

    Also - when I go to the 'custom colors' in excel and set the red, green and blue values to red: 255 green 255 blue 0 - I get the bright yellow but the 5296274 doesn't fit - each one (red,green,blue) values have a maximum setting of 255??

    Thanks for any help
    Last edited by pongmeister; 02-25-2018 at 10:21 PM. Reason: add more info

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Display colors next to list of hex color codes
    By tcebob in forum Excel General
    Replies: 9
    Last Post: 03-08-2017, 10:33 PM
  2. assign colors to graphs using color codes in a table
    By flummel in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-13-2016, 09:49 AM
  3. Background color of cell based on colors in column
    By mez275 in forum Excel General
    Replies: 1
    Last Post: 09-28-2013, 05:06 PM
  4. Cell background color (interior color) setting not working
    By Martin E. in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2006, 02:10 PM
  5. [SOLVED] Setting Background Color RGB (Always goes to closest index color)
    By ryanmhuc@yahoo.com in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-02-2005, 07:55 PM
  6. Conditionally setting background color of a cell
    By Scott Steiner in forum Excel General
    Replies: 1
    Last Post: 11-20-2005, 08:15 AM
  7. formatting background color of a cell with custom colors
    By sprasad in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-15-2005, 05:00 AM

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