Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

vba graphs excel

Forum home » Delegate support and help forum » Microsoft Excel Training and help » VBA for graphs in excel

VBA for graphs in excel

ResolvedVersion 2010

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.

Edited on Tue 24 Nov 2015, 10:59

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.

Mon 30 Nov 2015: Automatically marked as resolved.

Excel tip:

Customize the toolbar in Excel 2010

You can create your own toolbar which contains your favourite or most used tools. This will make using Excel much more efficient. To do this, you need to click on View, then select Customize Quick access Toolbars and then select Customize. A list of tools will then appear on the screen of which you can add or remove them as you please.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.