Ga naar hoofdinhoud

Hoe gegevens uit een diagram of grafiek te extraheren in Excel?

doc-extract-chart-data-1
In Excel gebruiken we meestal een diagram om gegevens en trends weer te geven voor een duidelijkere weergave, maar soms is het diagram een ​​kopie en hebt u niet de originele gegevens van het diagram zoals onderstaand screenshot. In dat geval wilt u wellicht de gegevens uit dit diagram extraheren. Deze tutorial heeft het nu over het extraheren van gegevens uit een diagram of grafiek.
Extraheer gegevens uit de grafiek met VBA

pijl blauw rechts bel Extraheer gegevens uit de grafiek met VBA

1. U moet een nieuw werkblad maken en het hernoemen als GrafiekData. Zie screenshot:

doc-extract-chart-data-5

2. Selecteer vervolgens het diagram waaruit u gegevens wilt extraheren en druk op Alt + F11 toetsen tegelijk, en a Microsoft Visual Basic voor toepassingen venster springt.

3. klikken Invoegen > Moduleen plak vervolgens onder VBA-code in de popping Module venster.

VBA: extraheer gegevens uit de grafiek.

Sub GetChartValues()
    'Updateby20220510
    Dim xNum As Integer
    Dim xSeries As Object
    On Error Resume Next
    xCount = 2
    xNum = UBound(Application.ActiveChart.SeriesCollection(1).Values)
    Application.Worksheets("ChartData").Cells(1, 1) = "X Values"
    With Application.Worksheets("ChartData")
        .Range(.Cells(2, 1), _
        .Cells(xNum + 1, 1)) = _
        Application.Transpose(ActiveChart.SeriesCollection(1).XValues)
    End With
    For Each xSeries In Application.ActiveChart.SeriesCollection
        Application.Worksheets("ChartData").Cells(1, xCount) = xSeries.Name
        With Application.Worksheets("ChartData")
            .Range(.Cells(2, xCount), _
            .Cells(xNum + 1, xCount)) = _
            Application.WorksheetFunction.Transpose(xSeries.Values)
        End With
        xCount = xCount + 1
    Next
End Sub

4. Dan klikken lopen knop om de VBA uit te voeren. Zie screenshot:

doc-extract-chart-data-2

Vervolgens kunt u zien dat de gegevens zijn geëxtraheerd naar GrafiekData vel.
doc-extract-chart-data-3

Tip:

1. U kunt de cellen naar wens opmaken.

doc-extract-chart-data-4

2. De gegevens van het geselecteerde diagram worden standaard geëxtraheerd naar de eerste cel van het ChartData-blad.


Tip: Als u meestal complexe grafieken in Excel gebruikt, wat lastig zal zijn omdat u ze heel vaak maakt, hier met de Auto-tekst tool van Kutools for Excel, u hoeft alleen de grafieken de eerste keer te maken en vervolgens de grafieken in het AutoTekst-paneel toe te voegen, en u kunt ze overal en altijd opnieuw gebruiken, u hoeft alleen de referenties te wijzigen zodat ze overeenkomen met uw werkelijke behoefte.  Klik voor gratis download het nu.
doc voorwaardelijke opmaak gestapeld staafdiagram 12

Beste Office-productiviteitstools

🤖 Kutools AI-assistent: Een revolutie teweegbrengen in de data-analyse op basis van: Intelligente uitvoering   |  Genereer code  |  Aangepaste formules maken  |  Analyseer gegevens en genereer grafieken  |  Roep Kutools-functies aan...
Populaire functies: Zoek, markeer of identificeer duplicaten   |  Verwijder lege rijen   |  Combineer kolommen of cellen zonder gegevens te verliezen   |   Ronde zonder formule ...
Super opzoeken: Meerdere criteria VLookup    VLookup met meerdere waarden  |   VOpzoeken over meerdere bladen   |   Fuzzy opzoeken ....
Geavanceerde vervolgkeuzelijst: Maak snel een vervolgkeuzelijst   |  Afhankelijke vervolgkeuzelijst   |  Multi-select vervolgkeuzelijst ....
Kolom Beheerder: Voeg een specifiek aantal kolommen toe  |  Kolommen verplaatsen  |  Schakel de zichtbaarheidsstatus van verborgen kolommen in  |  Vergelijk bereiken en kolommen ...
Uitgelichte functies: Raster focus   |  Ontwerpweergave   |   Grote formulebalk    Werkmap- en bladbeheer   |  resource Library (Auto-tekst)   |  Datumkiezer   |  Combineer werkbladen   |  Cellen coderen/decoderen    Stuur e-mails per lijst   |  Super filter   |   Speciaal filter (filter vet/cursief/doorhalen...) ...
Top 15 gereedschapsets12 Tekst Tools (toe te voegen tekst, Tekens verwijderen, ...)   |   50+ tabel Types (Gantt Chart, ...)   |   40+ Praktisch Formules (Bereken leeftijd op basis van verjaardag, ...)   |   19 Invoeging Tools (QR-code invoegen, Afbeelding invoegen vanaf pad, ...)   |   12 Camper ombouw Tools (Getallen naar woorden, Currency Conversion, ...)   |   7 Samenvoegen en splitsen Tools (Geavanceerd Combineer rijen, Gespleten cellen, ...)   |   ... en meer

Geef uw Excel-vaardigheden een boost met Kutools voor Excel en ervaar efficiëntie als nooit tevoren. Kutools voor Excel biedt meer dan 300 geavanceerde functies om de productiviteit te verhogen en tijd te besparen.  Klik hier om de functie te krijgen die u het meest nodig heeft...

Omschrijving


Office-tabblad Brengt een interface met tabbladen naar Office en maakt uw werk veel gemakkelijker

  • Schakel bewerken en lezen met tabbladen in Word, Excel, PowerPoint in, Publisher, Access, Visio en Project.
  • Open en maak meerdere documenten in nieuwe tabbladen van hetzelfde venster in plaats van in nieuwe vensters.
  • Verhoogt uw productiviteit met 50% en vermindert honderden muisklikken voor u elke dag!
Comments (18)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Amazing...
This comment was minimized by the moderator on the site
Very helpful! Thanks a lot!
This comment was minimized by the moderator on the site
giving error and tell to set block variables and object variables
This comment was minimized by the moderator on the site
Hi, I have updated the VBA, you can try it again.
This comment was minimized by the moderator on the site
i tried above & it says "Compile error: Method or Data Member not found"
This comment was minimized by the moderator on the site
mong mọi người giúp đỡ làm cách nào để lấy số liệu từ biểu đồ này với ạ!
This comment was minimized by the moderator on the site
i m getting below error while running that command.
this error comes in that command which starts from xnum = UBound(......) etc

Run-Time error '91'
object variable or with block variable not set
This comment was minimized by the moderator on the site
Hi, tarshul, you need to create a new worksheet named ChartData before you running the code, the data will be place in the new worksheet ChartData.
This comment was minimized by the moderator on the site
Hi sunny,
I already create new worksheet as u told but still getting same error.
This comment was minimized by the moderator on the site
This doesn't appear to work for a scatter plot as it only extracts one set of "x" data. How can I amend it to extract all "x" data sets?
This comment was minimized by the moderator on the site
Sorry I did not found the solution about that.
This comment was minimized by the moderator on the site
i've tried with a scatter plot graph as well, but only get one line of valor.


i need so much to find a way to extract data from scatterplot graphs.
This comment was minimized by the moderator on the site
I failed to get the prices of a fund chart on my mac excel 2011 . Run time error '91' object variable or block variable not set . Don't know how to debug . Appreciate any help .
This comment was minimized by the moderator on the site
Very useful and perfect
This comment was minimized by the moderator on the site
gives me values that i created chart with not all the values in range
This comment was minimized by the moderator on the site
Amazing command, thanks a lot! I used it with a pivot chart and it works!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations