PC Review


Reply
Thread Tools Rate Thread

Chart Generation. Changing interior color.

 
 
Dan
Guest
Posts: n/a
 
      29th May 2008
Here is my question.
I was able to adjust code according to my need and generate chart with data
in Sheet1. But, as it makes chart, I need to have white background instead of
gray. That requires to write code that converts gray area into white. But I
can't place it in the middle of code. It doesn't work there, or in a slightly
different way written it takes a while to change while running the code. Like
gray color would be for 2 or 3 seconds and then switch to white. Not very
fancy at all.

I had to place it at the very end of macro. Anyone, who has ideas how to
solve, please let me know. Code is below.

Sub AddChartSheet()
Dim chtChart As Chart
On Error Resume Next
'Delete chart if there is any
Application.DisplayAlerts = False
Charts("Tool Sales2").Delete
'Create a new chart.
Set chtChart = Charts.Add
With chtChart
.Name = "Tool Sales2"
.ChartType = xlLineMarkers
'Link to the source data range
.SetSourceData Source:=Sheets("Sheet1").Range("A15"), _
PlotBy:=xlRows
.HasTitle = True
.ChartTitle.Text = "=Sheet1!R1C2"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Sales"
End With
chtChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
End Sub

 
Reply With Quote
 
 
 
 
ward376
Guest
Posts: n/a
 
      29th May 2008
Dan - did you try turning off screen updating until after the chart's
created?

application.screenupdating = false
'make chart
application.screenupdating = true

Cliff Edwards
 
Reply With Quote
 
Dan
Guest
Posts: n/a
 
      29th May 2008


"ward376" wrote:

> Dan - did you try turning off screen updating until after the chart's
> created?
>
> application.screenupdating = false
> 'make chart
> application.screenupdating = true
>
> Cliff Edwards
> WOW! That is a very good trick! Thanks a lot Ed!

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      29th May 2008
Also, you can streamline the code by, for example, changing this

chtChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With

to this

With chtChart.PlotArea
With .Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
With .Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
End With

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Dan" <(E-Mail Removed)> wrote in message
news:7E1BBD68-C2B5-4949-98E3-(E-Mail Removed)...
>
>
> "ward376" wrote:
>
>> Dan - did you try turning off screen updating until after the chart's
>> created?
>>
>> application.screenupdating = false
>> 'make chart
>> application.screenupdating = true
>>
>> Cliff Edwards


WOW! That is a very good trick! Thanks a lot Ed!


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make font color oppose to cell interior color narke Microsoft Excel Discussion 4 31st May 2010 03:11 AM
Cell background color (interior color) setting not working Martin E. Microsoft Excel Programming 1 21st May 2006 07:00 PM
Range: changing interior color Jim Brass Microsoft Excel Programming 4 11th Nov 2005 04:06 AM
Events... Changing the Interior Color kraljb Microsoft Excel Programming 2 17th Jul 2005 06:58 PM
Passing Back Color to Interior Color ExcelMonkey Microsoft Excel Programming 1 22nd Mar 2005 04:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:34 PM.