Bonjour
j'ai ecrit cette macro pour faire un graphique en dynamique a partir d une selection manuelle,
cependant en arrivant à la définition du titre (phrase en gras dans le code)
j'ai une erreur "Run time error -2147024809 (80070057) This object has no tittle" qui arrive ,
si je mets cancel ça marche mais si j entre un nom pour le graphique ça marche pas,
pouvez vous m aider please ;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 Sub CreateChart() ' Create a new chart sheet from the table on Sheet2 ' by using the Add method of the Charts collection. Dim objSelection As Range, objChart As Chart ' Select the sheet that contains the data. ActiveWorkbook.Sheets("TCD_VOL").Select ' Prompt the user to select the range to chart ' and set the Range object to the specified range. Set objSelection = _ Application.InputBox(Prompt:="Select the columns and rows to chart", _ Default:=Selection.Address, _ Type:=8) ' Verify whether a selection was made. If objSelection.Cells.Count = 1 Then MsgBox "You must select at least one row or column for the chart range." Exit Sub End If ' Create a new chart sheet and specify its source data ' and appearance. Set objChart = Charts.Add With objChart .ChartType = xlColumnClustered '.SetSourceData objSelect .Location xlLocationAsNewSheet .Legend.Position = xlLegendPositionRight .PlotBy = xlColumns End With ' Ask the user whether to plot by rows instead. If MsgBox("Or plot by rows?", vbYesNo) = vbYes Then objChart.PlotBy = xlRows End If ' Prompt the user for a title. objChart.HasTitle = True objChart.ChartTitle.Text = InputBox("Title?") ' Ask the user whether to delete the chart. Application.DisplayAlerts = False If MsgBox("Delete chart?", vbYesNo) = vbYes Then ActiveSheet.Delete End If Application.DisplayAlerts = True End Sub
Partager