Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7592053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:48:32+00:00 2026-05-30T20:48:32+00:00

I have a VBA code in excel to change colors of bar graph but

  • 0

I have a VBA code in excel to change colors of bar graph but its not working for category series.

ActiveChart.SeriesCollection(1).Interior.Color = RGB(0, 153, 64) 

I want to change the color of a single bar. However, the above code changes the color of all bars.

For all bars I want one color (green) except for two bars representing two data points (Average1 and average2); these should be of a different color. Can anyone please tell me how to to this with VBA?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:48:34+00:00Added an answer on May 30, 2026 at 8:48 pm

    Jesse’s answer is often the cleanest way to do it.

    However, it is not accurate that “to have different colored bars they must be on different series” (my emphasis). You can mix and match colors within one series. For example, this makes the second bar of the first series red:

    ActiveChart.SeriesCollection(1).Points(2).Interior.Color = RGB(255, 0, 0)
    

    You can use this to do all kinds of neat tricks, such as highlighting bars that exceed some threshold, are associated with leap years, or whatever. You could certainly choose to highlight your average1 and average2 values this way.


    If you want to change the color for a point that has a given characteristic, then you have to loop through all points until you find a point that has that characteristic. For example, if you want to color in red the point whose category (XValue) is "avg" then you could do this:

    Dim c As Chart
    Dim s As Series
    Dim iPoint As Long
    Dim nPoint As Long
    
    Set c = ActiveChart
    Set s = c.SeriesCollection(1)
    
    nPoint = s.Points.Count
    For iPoint = 1 To nPoint
        If s.XValues(iPoint) = "avg" Then
            s.Points(iPoint).Interior.Color = RGB(255, 0, 0)
        End If
    Next iPoint
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code in excel to change colors of bar graph but its
I'm not sure why my code is not working.. I have code in vba
I have writen some code in VBA (Excel) with error handling labels. It worked
I have VBA code in an Excel spreadsheet. It is used to set the
I need to access the VBA code of Office documents (Excel workbooks, but it's
I have some VBA code in an Excel workbook. I have a cell which
I have created a C# library's COM object in VBA code (Excel). This C#
I have the following VBA code inside an Excel macro: With ActiveSheet.QueryTables.Add( _ Connection:=ConnStr,
I'm running Excel 2003. I have the following VBA code, corresponding to a simple
I have added a VBA code to my excel, what it does is automatically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.