I want to make a pie chart in Excel.
I’ve tried using invoke VBA and Balareva but it still doesn’t work. because the balareva package cannot be used on my UiPath.
Is there any way other than that to make a pie chart?
I want to make a pie chart in Excel.
I’ve tried using invoke VBA and Balareva but it still doesn’t work. because the balareva package cannot be used on my UiPath.
Is there any way other than that to make a pie chart?
Data Grafik.xlsx (395.0 KB)
The graph should be placed in column “E18”.
data is taken from column “A8:C8” later this column will be dynamic
I have a dynamic “Data Range” how can the robot read the data according to the header column “A1:C3”?
Hi @Kia1
You can use the following code
Sub Macro1()
Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1")
Dim chartDataRange As Range: Set chartDataRange = ws.Range("A8:C15")
Dim chartObj As ChartObject: Set chartObj = ws.ChartObjects.Add(Left:=ws.Range("E18").Left, Width:=375, Top:=ws.Range("E18").Top, Height:=225)
chartObj.Chart.ChartType = xlPie
chartObj.Chart.SetSourceData Source:=chartDataRange
End Sub
You need to save this code in the .txt file & you can call it using
Hope this helps
thank you very helpful
but can I make the data chart smaller and place it below the pie chart? Because you have to see all the column data
So can I set the data range? because for me the data will not still increase or decrease but the header remains in column “A8:C8”
Hi @Kia1
This will calculate the last row as we will have fix headers in A8:C8
Sub Macro1()
Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1")
Dim lastRow As Long
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
Dim chartDataRange As Range: Set chartDataRange = ws.Range("A8:C" & lastRow)
Dim chartObj As ChartObject: Set chartObj = ws.ChartObjects.Add(Left:=ws.Range("E18").Left, Width:=375, Top:=ws.Range("E18").Top, Height:=225)
chartObj.Chart.ChartType = xlPie
chartObj.Chart.SetSourceData Source:=chartDataRange
chartDataRange.Copy Destination:=ws.Range("E18").Offset(250, 0)
End Sub
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.