Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chart creation macro -VBA excel

Status
Not open for further replies.

ckaren000

Technical User
Aug 31, 2003
7
US
Hi everybody,
i have a question regarding chart creation in excel. i have the following code to create a chart and resize the plot area. what my problem is, while creating the chart we can see how it is being resized. i don't want users to see what it is doin. as soon as it is done with the chart i want to show it.
any help will be greatly appreciated
here is the code

Private Sub CommandButton1_Click()
fname = "test.xls"
sh1 = "Sheet1"
Workbooks.Open Filename:="C:\karen\test.xls"

Charts.Add
With ActiveChart
.ChartType = xlXYScatterSmoothNoMarkers
.SetSourceData Source:=Sheets(sh1).Range("E10:F14"), PlotBy _
:=xlColumns
.Location Where:=xlLocationAsNewSheet, Name:="result"
.HasTitle = True
.ChartTitle.Characters.Text = "title"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "x"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "y"
.HasLegend = False

.ChartArea.Border.Weight = xlHairline
.ChartArea.Border.LineStyle = xlAutomatic

.PageSetup.LeftMargin = Application.InchesToPoints(0.5)
.PageSetup.RightMargin = Application.InchesToPoints(0.5)
.PageSetup.TopMargin = Application.InchesToPoints(0.5)
.PageSetup.BottomMargin = Application.InchesToPoints(0.5)
.PageSetup.HeaderMargin = Application.InchesToPoints(0.5)
.PageSetup.FooterMargin = Application.InchesToPoints(0.5)

.PlotArea.Border.Weight = xlThin
.PlotArea.Border.LineStyle = xlAutomatic
.PlotArea.Interior.ColorIndex = 2
.PlotArea.Interior.PatternColorIndex = 1
.PlotArea.Interior.Pattern = xlSolid
.PlotArea.Width = 265
.PlotArea.Height = 232
.PlotArea.Left = 28
.PlotArea.Top = 45
.Axes(xlValue).Border.Weight = xlHairline
.Axes(xlValue).Border.LineStyle = xlAutomatic
.Axes(xlValue).MajorTickMark = xlOutside
.Axes(xlValue).MinorTickMark = xlNone
.Axes(xlValue).TickLabelPosition = xlLow
.Axes(xlValue).TickLabels.AutoScaleFont = True
.Axes(xlValue).TickLabels.Font.Name = "Arial"
.Axes(xlValue).TickLabels.Font.FontStyle = "Regular"
.Axes(xlValue).TickLabels.Font.Size = 9

.Axes(xlCategory).TickLabels.AutoScaleFont = True
.Axes(xlCategory).TickLabels.Font.Name = "Arial"
.Axes(xlCategory).TickLabels.Font.FontStyle = "Regular"
.Axes(xlCategory).TickLabels.Font.Size = 9
.Axes(xlCategory).AxisTitle.AutoScaleFont = True
.Axes(xlCategory).AxisTitle.Font.Name = "Arial"
.Axes(xlCategory).AxisTitle.Font.FontStyle = "Bold"
.Axes(xlCategory).AxisTitle.Font.Size = 9
.Axes(xlCategory).HasMajorGridlines = True
.Axes(xlCategory).HasMinorGridlines = False

.Axes(xlValue).AxisTitle.AutoScaleFont = True
.Axes(xlValue).AxisTitle.Font.Name = "Arial"
.Axes(xlValue).AxisTitle.Font.FontStyle = "Bold"
.Axes(xlValue).AxisTitle.Font.Size = 9
.Axes(xlValue).HasMajorGridlines = True
.Axes(xlValue).HasMinorGridlines = False


End With
End Sub

karen
 
Hi Karen,

Place this at the beginning. It will turn "Screen Updating" OFF:
Application.ScreenUpdating = False

Place this at the end. It will turn "Screen Updating" ON:
Application.ScreenUpdating = True

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top