Solved

VBA to set fill color on Excel Charts

Posted on 2013-12-23
5
690 Views
Last Modified: 2013-12-26
I have some code that someone helped me with
Sub ColourCells(rngIn As Range)
    Dim rngcell As Range
    Dim iColor As Long
    For Each rngcell In rngIn
        With rngcell
            Select Case .Value
     
                Case "Book Value per Share to Price", "Cashflow per Share to Price", "Dividend Yield", "Earnings per Share to Price", "EBITDA to EV", "EBITDA to Price", "IBES Dividend Yield", "IBES Earnings Yield", "IBES Sales Yield", "Sales per Share to Price", "Sales to EV", "Free Cashflow Yield"
         
                    iColor = 5
                    .Font.Color = RGB(255, 255, 255)
                     
                Case "Growth in Earnings per Share", "IBES 12 Month Forward  Growth in Earnings per Share", "IBES Earnings Long Term Growth", "IBES FY1  Earnings Revisions 1M Sample", "IBES FY1  Earnings Revisions 3M Sample", "IBES FY2  Earnings Revisions 1M Sample", "IBES FY2  Earnings Revisions 3M Sample", "IBES Sales 12 Mth Growth", "IBES Sales Long Term Growth", "Income to Sales", "Return on Equity", "Sales Growth", "Sustainable Growth Rate"
         
                    iColor = 10
                    .Font.Color = RGB(255, 255, 255)
                    
                Case "Beta", "Market Cap (Large Cap)*"
         
                    iColor = 3
                    .Font.Color = RGB(255, 255, 255)
                     
                Case "Momentum 12 Mth", "Momentum 6 Mth", "Momentum Short Term (6 Month Exp Wtd)"
         
                    iColor = 1
                    .Font.Color = RGB(255, 255, 255)
                     
                Case "Debt to Equity", "Foreign Sales as a % Total Sales"
         
                    iColor = 6
                    .Font.Color = RGB(0, 0, 0)
                     
                Case "Low Gearing", "Low Accruals", "Stability Of Earnings Growth", "Stability Of FY1 Revisions", "Stability Of IBES 12 Mth Growth Forecast", "Stability of Returns", "Stability Of Sales Growth"
         
                    iColor = 18
                    .Font.Color = RGB(255, 255, 255)
                Case Else
         
                    'Whatever
         
            End Select
         
             
         
            .Interior.ColorIndex = iColor
        End With
    Next rngcell
 
End Sub

Open in new window

awhile ago.  I need to be able to use the RGB colors instead of what I am currently using for fill colors on excel bar charts.
0
Comment
Question by:majervis
  • 3
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39736606
0
 

Author Comment

by:majervis
ID: 39736791
Thank you.  Is it not possible to use the RGB way of creating colors.  I don't have any knowledge about this.  Just curious.
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39736793
It depends on which Version of Excel you have
0
 

Author Comment

by:majervis
ID: 39736881
2010
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39736897
instead of .Colorindex use .Color
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Office 2016 vs o365 4 82
outlook 2016 orgnize ideas 2 86
Microsoft Access 2010 Question 2 76
How to take a hard copy form and make it a fillable soft form? 9 46
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question