Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
HOw can I change the background and foreground color of an excel graph?
I tried : ------------------------------------ With myChart.ChartArea.Fill .Visible = True .ForeColor.SchemeColor = 15 .BackColor.SchemeColor = 17 End With ------------------------------------ the background color changes but the foreground does not change...Does foreground here mean the grey area because thats the color I want to change. Thanks -- Message posted via http://www.officekb.com |
#2
![]() |
|||
|
|||
![]()
If you are working with an embedded chart, select the outside of the chart
and run this macro: Sub ChangeColors1() ActiveChart.ChartArea.Interior.ColorIndex = 8 ActiveChart.PlotArea.Interior.ColorIndex = 7 End Sub To change the ChartArea and PlotArea colors for all embedded charts on the worksheet, you can use something like this: Sub ChangeColors2() Dim ChtObj As ChartObject For Each ChtObj In ActiveSheet.ChartObjects ChtObj.Interior.ColorIndex = 4 ChtObj.Chart.PlotArea.Interior.ColorIndex = 3 Next ChtObj End Sub If you're using a chart sheet, try: Sub ChangeColors3() Dim Cht As Chart Set Cht = Sheets("Chart2") Cht.ChartArea.Interior.ColorIndex = 8 Cht.PlotArea.Interior.ColorIndex = 7 End Sub -- Regards, John Mansfield http://www.pdbook.com "Cenk Ursavas via OfficeKB.com" wrote: HOw can I change the background and foreground color of an excel graph? I tried : ------------------------------------ With myChart.ChartArea.Fill .Visible = True .ForeColor.SchemeColor = 15 .BackColor.SchemeColor = 17 End With ------------------------------------ the background color changes but the foreground does not change...Does foreground here mean the grey area because thats the color I want to change. Thanks -- Message posted via http://www.officekb.com |
#3
![]() |
|||
|
|||
![]()
I have a similar dilemma, but have yet to figure-out the solution.
Sheet 1, cell A1 contains +1, 0 or -1 (derived from contents of another workbook). Sheet 2 contains an imbedded line chart. How does one dynamically code for the 'chart area', (leaving the 'plot area' as-is), of the chart in sheet 2 to be: a) green if Sheet1,A1 is +1 b) grey if Sheet 1, A1 is 0 c) red if Sheet 1, A1 is -1 ??? "John Mansfield" wrote: If you are working with an embedded chart, select the outside of the chart and run this macro: Sub ChangeColors1() ActiveChart.ChartArea.Interior.ColorIndex = 8 ActiveChart.PlotArea.Interior.ColorIndex = 7 End Sub To change the ChartArea and PlotArea colors for all embedded charts on the worksheet, you can use something like this: Sub ChangeColors2() Dim ChtObj As ChartObject For Each ChtObj In ActiveSheet.ChartObjects ChtObj.Interior.ColorIndex = 4 ChtObj.Chart.PlotArea.Interior.ColorIndex = 3 Next ChtObj End Sub If you're using a chart sheet, try: Sub ChangeColors3() Dim Cht As Chart Set Cht = Sheets("Chart2") Cht.ChartArea.Interior.ColorIndex = 8 Cht.PlotArea.Interior.ColorIndex = 7 End Sub -- Regards, John Mansfield http://www.pdbook.com "Cenk Ursavas via OfficeKB.com" wrote: HOw can I change the background and foreground color of an excel graph? I tried : ------------------------------------ With myChart.ChartArea.Fill .Visible = True .ForeColor.SchemeColor = 15 .BackColor.SchemeColor = 17 End With ------------------------------------ the background color changes but the foreground does not change...Does foreground here mean the grey area because thats the color I want to change. Thanks -- Message posted via http://www.officekb.com |
#4
![]() |
|||
|
|||
![]()
Borrowed and adapted from Jim Cone's example in Subject: help new to vba
- charts?? 2/27/2005 4:50 PM PST By: Jim Cone In: microsoft.public.excel.programming You can quickly see examples of the chartarea colors available to you by doing the following: 1. From your sheet that contains a chart, select "Restore Down" (upper-right on the display-screen, middle box). This displays a smaller, but adequate, view of your chart. 2. From the display that results from step 1, open the Visual Basic Editor under Tools, Macro, Visual Basic Editor. Or, select Alt+F11. Either should result in the same display of the Visual Basic Editor. 3. Copy this code into the Visual Basic Editor: Sub ColorTest() Dim chtRate As Excel.Chart Dim lngColor As Long 'Make an object reference to the chart within the ChartObject Set chtRate = ActiveSheet.ChartObjects(1).Chart 'What is the current color? lngColor = chtRate.ChartArea.Interior.ColorIndex 'Good, now make the next color lngColor = lngColor + 1 'Show the next chartarea color chtRate.ChartArea.Interior.ColorIndex = lngColor Set chtRate = Nothing End Sub 4. On the bottom of your PC display, left-click the Microsoft Excel button. This should result in your screen showing two Window items: a) Your chart and b) the Visual Basic Editor. 5. At the top of your Visual Basic Editor window, there's an arrow pointing right (just under the word "Debug"). When you point your mouse at it, a "popup text" says "Run Sub/UserForm". Left-click that arrow. 6. Every time you left-click the "Run Sub/UserForm" arrow, you should see your chart's chartarea change color. This will show you several-dozen colors that you can use for your chartarea. If you haven't decided what looks best, keep clicking :-) You will continue to see different colors until you do. "Cenk Ursavas via OfficeKB.com" wrote: HOw can I change the background and foreground color of an excel graph? I tried : ------------------------------------ With myChart.ChartArea.Fill .Visible = True .ForeColor.SchemeColor = 15 .BackColor.SchemeColor = 17 End With ------------------------------------ the background color changes but the foreground does not change...Does foreground here mean the grey area because thats the color I want to change. Thanks -- Message posted via http://www.officekb.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sheet Background Color | Excel Discussion (Misc queries) | |||
background color of my cell does not change | Excel Discussion (Misc queries) | |||
how do I change the default background color in excel? | Setting up and Configuration of Excel | |||
Change background color | Excel Discussion (Misc queries) | |||
background color showing only when in email form | Excel Discussion (Misc queries) |