excel vba charts
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel VBA - Charts

Excel VBA - Charts

resolvedResolved · Low Priority · Version 2003

replyReply Thu 23 Oct 2008, 16:27Delegate Michael said...

Michael has attended:
Excel Advanced course
Excel VBA Intro Intermediate course
Access VBA course

Excel VBA - Charts

Is it possible to amend the 'source data' range with VBA when constructing/updating excel charts ?

For upcoming training course dates see: Pricing & availability

replyReply Thu 23 Oct 2008, 17:53Trainer Katie said...

RE: Excel VBA - Charts

Hi Michael,

Thank you for your question. Whenever you wish to change any data, you should set it as a Variable. In this case, SourceData should be set as a range variable.

Assuming your sourcedata always start in cell "A1" of worksheet "Sheet 1", see the sample codes below:

====================================
Sub MakeChart()

Dim SourceData As Range

Set SourceData = Range("A1", Range("A1").End(xlToRight).End(xlDown))

Charts.Add

ActiveChart.SetSourceData Source:=SourceData
ActiveChart.Location Where:=xlLocationAsNewSheet

Sheets("Sheet1").Select

End sub

====================================

Hope this is useful

Kind regards,

Katie Woo
Microsoft Certified Trainer

 

Please browse our web site to find out more about
vba-excel-training and other Microsoft training courses.

Excel tip:

Pivot table grouping

If you want to group items in a pivot table together, simply highlight the labels for the fields either with the shift key (if adjacent)or with the contral key if they are not next to each other.
Right click and choose group. Give the cell a name.

When you double click on this cell it will either expamd or collapse your grouped area

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard