Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-18-2017, 02:33 AM
Filip88 Filip88 is offline Multiple Chartobjects in VBA Windows 10 Multiple Chartobjects in VBA Office 2016
Novice
Multiple Chartobjects in VBA
 
Join Date: Jan 2017
Posts: 12
Filip88 is on a distinguished road
Default Multiple Chartobjects in VBA

Hello,

Could pls anybody explain me how to refer to a chartobjects in case of multiple chartobjects are created in excel (via VBA)?

i have 1st macro, creating a chart, and the 2nd macro that should delete the same chart. Howerver i dont know how to specify or refer by the 2nd macro to this one specific chart, created by the 1st macro. When for example i create more charts in the sheet manually, the 2nd macro will delete only chart in ChartObjects(1).. i need somehow refer to only that chart, created by the 1st macro.

When i create the chart, can i somehow set fixed chartobject of the chart that will not change in case of any other multiple charts in excel?

MACRO TO CREATE CHART
Code:
Sub CreateChart()

Dim MyChart As Chart

Dim DataRange As Range
Set DataRange = ActiveSheet.Range("A1:A7")

Set MyChart = Worksheets("List1").Shapes.AddChart(x1linemarkers, 673, 250, 380, 150).Chart

MyChart.SetSourceData Source:=DataRange

With MyChart

.HasTitle = True
.ChartTitle.Text = Worksheets("List1").Range("A10")

End With
 
End If

End Sub
MACRO TO DELETE CHART


Code:
 
Sub Delete_main()

Worksheets("List1").ChartObjects(1).Delete

End If
End Sub
Thank you for help

Filip
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Chartobjects in VBA I need to add multiple values based on multiple criteria in a cell not sure what to do AUHAMM Excel 3 10-27-2014 09:11 PM
Create multiple copies of same email in multiple folders gaker10 Outlook 0 10-06-2014 07:44 AM
Multiple Chartobjects in VBA Copy Multiple Rows to new workbook when multiple criteria is met. flds Excel Programming 5 09-30-2014 09:58 AM
Multiple Chartobjects in VBA Multiple Multiple-level lists connected to each other PeterKottas Word 2 05-19-2014 04:39 AM
Multiple Input, Multiple Digital Signatures Jeff Word 0 01-04-2012 09:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft