› Excel e gli applicativi Microsoft Office › Conoscere il nome di un grafico selezionato
-
AutoreArticoli
-
SalveVorrei venire a conoscenza del nome di un qualsiasi grafico che ho selezionato cliccandoci sopra.Ho scritto questa riga
Dim chartName As String
chartName = ActiveChart.Namema invece di restituirmi il nome del grafico, che nel mio caso e' "Chart 4" mi da "Sheet1 Chart 4", ovvero comprende anche il nome del foglio in uso.Esiste un altro metodo per venire a conoscenza del nome del grafico?GrazieCiaoProva con questa macro (scrive il nome nella col.J)Sub Nome() Dim x As Integer, i As Integer x = ActiveSheet.Shapes.Count For i = 1 To x Cells(i, 10) = ActiveSheet.Shapes(i).Name Next i End SubFai sapere. Ciao,
MarioCiao Mario e graziemi serve una cosa lievemente diversaL'ideale sarebbe se esistesse un metodo come ActiveShape (ma non esiste lo so) per poter farechartName = ActiveSheet.ActiveShapes.NameCome ti ho detto esiste ActiveChart, ma mi restituisce il nome del foglio + quello del graficoGrazieCiaoMa appunto per quello ti ho suggerito la macro!Se vuoi assegnare ad una variabile il nome del Grafico, basta sostituire a Cells(i,10) il nome della variabile (anche ChartName) ma facendo attenzione se si hanno diverse Shapes nel Foglio.Ciao,MarioPuo essere utile al fine di capire quale grafico è selezionato.
Determining Whether a Chart Is
Activated
A common type of macro performs some manipulations on the active
chart (the chart selected by a user). For example, a macro might
change the chart's type, apply a style, add data labels, or export the
chart to a graphics file.
The question is how can your VBA code determine whether the user
has actually selected a chart? By selecting a chart, I mean either
activating a chart sheet or activating an embedded chart by clicking it.
Your first inclination might be to check the TypeName property of the
Selection, as in this expression:
TypeName(Selection) = “Chart”
In fact, this expression never evaluates to True. When a chart is
activated, the actual selection will be an object within the Chart
object. For example, the selection might be a Series object, a
ChartTitle object, a Legend object, or a PlotArea object.
The solution is to determine whether ActiveChart is Nothing. If so, a
chart isn't active. The following code checks to ensure that a chart is
active. If not, the user sees a message, and the procedure ends:
If ActiveChart Is Nothing Then
MsgBox “Select a chart.”
Exit Sub
Else
‘other code goes here
End If
You may find it convenient to use a VBA function procedure to
determine whether a chart is activated. The ChartIsSelected function,
which follows, returns True if a chart sheet is active or if an embedded
chart is activated, but returns False if a chart isn't activated:
Private Function ChartIsActivated() As Boolean
ChartIsActivated = Not ActiveChart Is Nothing
End FunctionQual è il punto di avere gusti diversi, se non mostrare che i cervelli lavorano diversamente, che pensiamo diversamente?( Alan Turing)
-
AutoreArticoli
