Avtar has attended:
Excel VBA Introduction course
VBA for graphs in excel
How can I use VBA to plot and format graphs of specific all rows and columns except a few header rows, and a few columns (specified by their title).
Specifically the formatting to make them consistent.
RE: VBA for graphs in excel
Hi again Avtar
Here is a macro that plots a graph. The data is in a range
A2:D6 on Sheet1 including a header in A2:D2
SalesRep Jan Feb Mar
Smith 1,800 1,766 1,942
Brown 1,704 1,809 1,650
Wallace 2,009 2,195 2,159
Adams 1,948 1,725 1,870
Sub createChart1()
Range("A3").Select
Charts.Add
With ActiveChart
.ChartType = xlColumnClustered
.PlotBy = xlRows
.HasTitle = True
.ChartTitle.Text = "Sales Figures"
.PlotArea.Interior.Color = vbYellow
.ChartArea.Interior.Color = RGB(100, 100, 200)
.SetSourceData Source:=Sheets("Sheet1").Range("a2:d6")
.Location where:=xlLocationAsObject, Name:="Sheet1"
' See Peltier to resize and position chart
' http://peltiertech.com/Excel/ChartsHowTo/ResizeAndMoveAChart.html
End With
' With ActiveChart.Parent
' .Height = 200 ' resize (units in points 72 = 1 inch)
' .Width = 300 ' resize
' .Top = 110 ' reposition
' .Left = 0 ' reposition
'End With
End Sub
I've included a link to Jon Peltier about resizing and positioning charts. Hope it will help you with formatting the chart as well.
Hope that helps for now
Regards :)
Doug
Best STL
Will be marked as resolved in 5 days
Notice: This is an automated message. Due to inactivity, this forum post will be marked as 'resolved' if there are no further responses in the next 5 days.