Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Cenk Ursavas via OfficeKB.com
 
Posts: n/a
Default background-foreground color

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   Report Post  
John Mansfield
 
Posts: n/a
Default

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   Report Post  
silver23
 
Posts: n/a
Default

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   Report Post  
silver23
 
Posts: n/a
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sheet Background Color Bill Helbron Excel Discussion (Misc queries) 2 April 14th 05 04:31 PM
background color of my cell does not change Colorblinded Excel Discussion (Misc queries) 2 March 27th 05 04:55 PM
how do I change the default background color in excel? B Walsh Setting up and Configuration of Excel 1 March 16th 05 06:08 PM
Change background color Andrew Clark Excel Discussion (Misc queries) 3 March 16th 05 04:14 AM
background color showing only when in email form David Excel Discussion (Misc queries) 1 January 23rd 05 09:46 PM


All times are GMT +1. The time now is 09:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"