Domanda

Ho dati sulle vendite mensili memorizzati in fogli separati. Vorrei creare un diagramma delle vendite per più prodotti al mese. Ogni prodotto verrebbe rappresentato in una linea colorata diversa sullo stesso grafico con ogni mese che corre lungo l'asse x.

Qual è il modo migliore per creare un grafico a linea singola che estrae dalle stesse celle relative su più fogli?

È stato utile?

Soluzione

Utilizza la Creazione guidata grafico.

Al passaggio 2 di 4, c'è una scheda etichettata "Serie". Ci sono 3 campi e una casella di riepilogo in questa scheda. La casella di riepilogo mostra le diverse serie che stai già includendo nel grafico. Ogni serie ha sia un " Nome " campo e un "Valori" campo specifico per quella serie. Il campo finale è rappresentato dalle etichette dell'asse " Categoria (X) " campo, che è comune a tutte le serie.

Fai clic su " Aggiungi " pulsante sotto la casella di riepilogo. Ciò aggiungerà una serie vuota alla casella di riepilogo. Nota che i valori per " Nome " e per "Valori" cambia quando si evidenzia una serie nella casella di riepilogo.

Seleziona le tue nuove serie.

C'è un'icona in ogni campo sul lato destro. Questa icona consente di selezionare celle nella cartella di lavoro da cui estrarre i dati. Quando si fa clic su di esso, la procedura guidata si nasconde temporaneamente (tranne per il campo in cui si sta lavorando) consentendo di interagire con la cartella di lavoro.

Seleziona il foglio appropriato nella cartella di lavoro e quindi seleziona i campi con i dati che vuoi mostrare nel grafico. È possibile fare clic sul pulsante a destra del campo per scoprire la procedura guidata.

Spero che sia d'aiuto.

EDIT: quanto sopra si applica al 2003 e prima. Per il 2007, quando viene selezionato il grafico, dovresti essere in grado di eseguire un'azione simile utilizzando " Seleziona dati " opzione sull'opzione " Design " scheda del nastro. Questo apre una finestra di dialogo che elenca le serie per il grafico. Puoi selezionare le serie esattamente come in Excel 2003, ma devi utilizzare " Aggiungi " e " Modifica " pulsanti per definire serie personalizzate.

Altri suggerimenti

Ecco un po 'di codice di Excel 2010 che potrebbe funzionare. Ha un paio di specifiche (come il filtraggio di caratteri con codifica errata dai titoli) ma è stato progettato per creare grafici multi-serie multipli da dati a 4 dimensioni con dati assoluti e basati su percentuale. Modificalo come preferisci:

Sub createAllGraphs()

Const chartWidth As Integer = 260
Const chartHeight As Integer = 200




If Sheets.Count = 1 Then
    Sheets.Add , Sheets(1)
    Sheets(2).Name = "AllCharts"
ElseIf Sheets("AllCharts").ChartObjects.Count > 0 Then
    Sheets("AllCharts").ChartObjects.Delete
End If
Dim c As Variant
Dim c2 As Variant
Dim cs As Object
Set cs = Sheets("AllCharts")
Dim s As Object
Set s = Sheets(1)

Dim i As Integer


Dim chartX As Integer
Dim chartY As Integer

Dim r As Integer
r = 2

Dim curA As String
curA = s.Range("A" & r)
Dim curB As String
Dim curC As String
Dim startR As Integer
startR = 2

Dim lastTime As Boolean
lastTime = False

Do While s.Range("A" & r) <> ""

    If curC <> s.Range("C" & r) Then

        If r <> 2 Then
seriesAdd:
            c.SeriesCollection.Add s.Range("D" & startR & ":E" & (r - 1)), , False, True
            c.SeriesCollection(c.SeriesCollection.Count).Name = Replace(s.Range("C" & startR), "Â", "")
            c.SeriesCollection(c.SeriesCollection.Count).XValues = "='" & s.Name & "'!$D<*>quot; & startR & ":$D<*>quot; & (r - 1)
            c.SeriesCollection(c.SeriesCollection.Count).Values = "='" & s.Name & "'!$E<*>quot; & startR & ":$E<*>quot; & (r - 1)
            c.SeriesCollection(c.SeriesCollection.Count).HasErrorBars = True
            c.SeriesCollection(c.SeriesCollection.Count).ErrorBars.Select
            c.SeriesCollection(c.SeriesCollection.Count).ErrorBar Direction:=xlY, Include:=xlBoth, Type:=xlCustom, Amount:="='" & s.Name & "'!$F<*>quot; & startR & ":$F<*>quot; & (r - 1), minusvalues:="='" & s.Name & "'!$F<*>quot; & startR & ":$F<*>quot; & (r - 1)
            c.SeriesCollection(c.SeriesCollection.Count).ErrorBar Direction:=xlX, Include:=xlBoth, Type:=xlFixedValue, Amount:=0

            c2.SeriesCollection.Add s.Range("D" & startR & ":D" & (r - 1) & ",G" & startR & ":G" & (r - 1)), , False, True
            c2.SeriesCollection(c2.SeriesCollection.Count).Name = Replace(s.Range("C" & startR), "Â", "")
            c2.SeriesCollection(c2.SeriesCollection.Count).XValues = "='" & s.Name & "'!$D<*>quot; & startR & ":$D<*>quot; & (r - 1)
            c2.SeriesCollection(c2.SeriesCollection.Count).Values = "='" & s.Name & "'!$G<*>quot; & startR & ":$G<*>quot; & (r - 1)
            c2.SeriesCollection(c2.SeriesCollection.Count).HasErrorBars = True
            c2.SeriesCollection(c2.SeriesCollection.Count).ErrorBars.Select
            c2.SeriesCollection(c2.SeriesCollection.Count).ErrorBar Direction:=xlY, Include:=xlBoth, Type:=xlCustom, Amount:="='" & s.Name & "'!$H<*>quot; & startR & ":$H<*>quot; & (r - 1), minusvalues:="='" & s.Name & "'!$H<*>quot; & startR & ":$H<*>quot; & (r - 1)
            c2.SeriesCollection(c2.SeriesCollection.Count).ErrorBar Direction:=xlX, Include:=xlBoth, Type:=xlFixedValue, Amount:=0
            If lastTime = True Then GoTo postLoop
        End If

        If curB <> s.Range("B" & r).Value Then

            If curA <> s.Range("A" & r).Value Then
                chartX = chartX + chartWidth * 2
                chartY = 0
                curA = s.Range("A" & r)
            End If

            Set c = cs.ChartObjects.Add(chartX, chartY, chartWidth, chartHeight)
            Set c = c.Chart
            c.ChartWizard , xlXYScatterSmooth, , , , , True, Replace(s.Range("B" & r), "Â", "") & " " & s.Range("A" & r), s.Range("D1"), s.Range("E1")

            Set c2 = cs.ChartObjects.Add(chartX + chartWidth, chartY, chartWidth, chartHeight)
            Set c2 = c2.Chart
            c2.ChartWizard , xlXYScatterSmooth, , , , , True, Replace(s.Range("B" & r), "Â", "") & " " & s.Range("A" & r) & " (%)", s.Range("D1"), s.Range("G1")

            chartY = chartY + chartHeight
            curB = s.Range("B" & r)
            curC = s.Range("C" & r)
        End If

        curC = s.Range("C" & r)
        startR = r
    End If

    If s.Range("A" & r) <> "" Then oneMoreTime = False ' end the loop for real this time
    r = r + 1
Loop

lastTime = True
GoTo seriesAdd
postLoop:
cs.Activate

End Sub

Il 2007 è più potente con la barra multifunzione ..: =) Per aggiungere nuove serie nel grafico, procedi come segue: Seleziona Grafico, quindi fai clic su Progetta in Strumenti grafico sulla barra multifunzione, Nella barra multifunzione Design, seleziona " Seleziona dati " nel gruppo di dati, Quindi vedrai il pulsante Aggiungi per aggiungere nuove serie.

Spero che possa aiutare.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top