Consulting

Results 1 to 5 of 5

Thread: Color Chart Columns by Conditionally Formatted Cell Color

  1. #1
    VBAX Regular
    Joined
    Oct 2017
    Posts
    14
    Location

    Color Chart Columns by Conditionally Formatted Cell Color

    table1.JPG
    Category color is Conditionally Formatted based on Text (i.e. cell color will change automatically with change of letter).

    Goal: Automatically color each column in chart with same color as in category (based on Conditional Formatting).

    chart1.JPG

    Is someone out there that could help me to reach my goal?

    arns

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    adopted from:

    Sub vbax_61383_Color_Chart_Columns_Based_on_Conditional_formatting()
        
        Dim vAddress As Range
        Dim i As Long, ColorVal As Long
        Dim R As Long, G As Long, B As Long
        
        With Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection(1) 'change sheet and chart references to suit
            Set vAddress = ActiveSheet.Range(Split(Split(.Formula, ",")(1), "!")(1)).Columns(2) 'X values from col A and B. so set range to the second col, ie col B
            For i = 1 To vAddress.Cells.Count
                ColorVal = vAddress.Cells(i).DisplayFormat.Interior.Color 'Displayformat to return conditional formatting color
                R = ColorVal Mod 256 'return RED value from ColorVal
                G = (ColorVal \ 256) Mod 256 'return GREEN value from ColorVal
                B = (ColorVal \ 256 \ 256) Mod 256 'return BLUE value from ColorVal
                .Points(i).Format.Fill.ForeColor.RGB = RGB(R, G, B)
            Next i
        End With
    
    End Sub
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    VBAX Regular
    Joined
    Oct 2017
    Posts
    14
    Location
    Spot on excellent! Exactly what I was looking for.
    Thank you mancubus.

  5. #5
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    you are welcome.

    thanks for the feedback and marking the thread as solved.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

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