+ Reply to Thread
Results 1 to 3 of 3

Thread: Color Combo box for a Bar Graph

  1. #1
    Registered User
    Join Date
    03-02-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Color Combo box for a Bar Graph

    Could some body enlighten me about how to create a combo box linked to a Bar graph that let me change its bar background color? Thxs

  2. #2
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,520

    Re: Color Combo box for a Bar Graph

    Here is the basic approach. I've put the code into a standard module, though it could just as well be run in the worksheet_change event.

    Option Explicit
    
    Sub Change_Chart_Series_Color()
    
        Dim icolor As Integer
        Dim Bar As ChartObject
    
        Select Case Range("E1").Value 'cell linked to combo box
            Case 1: icolor = 3 'red
            Case 2: icolor = 6 ' yellow
            Case 3: icolor = 41 ' blue
        End Select
        
        For Each Bar In ActiveSheet.ChartObjects
            If Bar.Chart.ChartType = xlColumnClustered Then
                Bar.Chart.SeriesCollection(1).Interior.ColorIndex = icolor
            End If
        Next Bar
    
    End Sub
    For more help, search the Forum using terms like Conditionally Color Chart Series
    Attached Files Attached Files
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    03-02-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Color Combo box for a Bar Graph

    Thanks Palmetto.You still honoring your title.
    Last edited by teylyn; 03-30-2010 at 08:12 PM. Reason: removed spurious quote

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0