Nils_Junker
Board Regular
- Joined
- Jun 2, 2023
- Messages
- 80
- Office Version
- 365
- Platform
- Windows
Hi everybody,
I want to change the color pallet of my diagram which gets produced automatically.
my color pallet would be the following: (RGB(0, 0, 201), RGB(0, 149, 255), RGB(13, 189, 186), RGB(103, 187, 110), RGB(157, 115, 247), RGB(217, 87, 118), RGB(244, 156, 52), RGB(248, 223, 90), RGB(244, 221, 186), RGB(127, 127, 127), RGB(140, 80, 8), RGB(0, 0, 100))
My code for producing the chart is the following
Thanks for your help!
I want to change the color pallet of my diagram which gets produced automatically.
my color pallet would be the following: (RGB(0, 0, 201), RGB(0, 149, 255), RGB(13, 189, 186), RGB(103, 187, 110), RGB(157, 115, 247), RGB(217, 87, 118), RGB(244, 156, 52), RGB(248, 223, 90), RGB(244, 221, 186), RGB(127, 127, 127), RGB(140, 80, 8), RGB(0, 0, 100))
My code for producing the chart is the following
VBA Code:
Dim DiagrammObjekt As chartObject
Dim DatenBereich As range
Dim DiagrammBereich As range
Dim colorPalette() As Variant
' Definiere den Datenbereich
Set DatenBereich = ThisWorkbook.Sheets("Tabelle1").range("C202:BD213")
' Definiere den Bereich für das Diagramm
Set DiagrammBereich = ThisWorkbook.Sheets("Tabelle1").range("A207")
' Erstelle das Liniendiagramm
Set DiagrammObjekt = ThisWorkbook.Sheets("Tabelle1").ChartObjects.Add( _
Left:=DiagrammBereich.Left, _
Width:=500, _
Top:=DiagrammBereich.Top, _
Height:=300)
' Fülle das Diagramm mit Daten aus dem Datenbereich
With DiagrammObjekt.chart
.SetSourceData Source:=DatenBereich
.ChartType = xlLine ' Ändere den Diagrammtyp hier nach Bedarf
.HasTitle = True
.ChartTitle.Text = "1. Diagramm"
End With
Thanks for your help!