Consulting

Results 1 to 10 of 10

Thread: Required VBA code to change Color of chart & also formatting

  1. #1

    Required VBA code to change Color of chart & also formatting


  2. #2
    Color-chart-columns-by-cell-color.xlsm

    sample VBA Macro file file attached for reference

  3. #3
    one more sample sheet attached with macro.in this sheet chart data color change by vertical & i want it will be change horizontally,can you modified this?

  4. #4

  5. #5
    Good Morning All

    Can any one help me on this issue?

  6. #6
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    Hi amartakale!
    Maybe this is useful.
    Sub ColorChartBarsbyCellColor1()
    Dim txt As String, i As Integer
    c = ActiveChart.SeriesCollection.Count
    For i = 1 To c
        txt = ActiveChart.SeriesCollection(i).Formula
        arr = Split(txt, ",")
        With ActiveChart.Legend.LegendEntries(i)
            Set vaddress = ActiveSheet.Range(arr(2))
            .LegendKey.Interior.Color = vaddress.Cells(1).Interior.Color
        End With
    Next i
    End Sub

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,057
    Location
    Actually I take exception to the poor communication attached to this particular thread. Whilst the thread title suggests something, its the very lack of a detailed explanation, which sums up why most people will simply bypass this thread.

    Take the time to clearly set out the issue. Describe what it is that you think you need as a end result for the issue and then you will find other wanting to assist.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  8. #8
    Thanks Sir,sorry for late reply.Next time I take care for complicated Question.

    Above code is perfect for Bar Chart (if horizontal data) then perfect work for color.

    but there are different type of chart in my work how to modified this code to all Chart (Bar Chart,Pie Chart,Line Chart....also Data are Horizontal & Vertical way).If I change data color without heading then Chart color change by VBA automatically ,how it can possible?

    Thanks once again

  9. #9
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,057
    Location
    Really? How about telling the people what you think the issue is, what you would like as a result? Then we can decide what assistance we might be able to offer. Any other request such as post @8 is rude. Please think clearly about the fact you are posting to a world wide audience therefore what you might post to another person in India wont work here.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  10. #10
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    You can judge chart types for different processing.
    The appendix is a simple example.
    Attached Files Attached Files

Posting Permissions

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