filmov
tv
Pie Chart Excel Using ChatGPT Prompts | Step-by-Step Tutorial | ChatGPT-VBA

Показать описание
In this video, we’ll show you how to create stunning pie charts in Excel effortlessly using ChatGPT prompts. Learn how to:
Write effective prompts to automate pie chart creation.
Customize your chart with colors, labels, and layouts.
Save time and enhance your workflow with AI-powered solutions.
Whether you're a beginner or an Excel pro, this tutorial will help you take your skills to the next level. Subscribe to Prompt School for more smart solutions
Motto: - “Create Pie Chart In Excel”
Prompt:
I want to create a Pie Chart in Excel using VBA. Please provide the complete VBA code with the following requirements:
1. Set the data range (A1:B7) from the active sheet.
2. Include data labels showing both the category name and value.
3. Label Option: - Values Outside End, Label Contain Category Name with values. Values in Bold
4. Set custom colors for each slice (using Hex color codes).
a. Slice 1: #FF7F50, Slice 2: #DE3163, Slice 3: #6495ED, Slice 4: #FFBF00, Slice 5: #800000, Slice 6: #008080
5. Apply Pie Explosion of 5% for all slices.
6. Set explosion for Series 1 (Slice 1) to 27%.
7. Set Legend options (left position).
8. Set the chart title. Chart Title “Prompt Agent”
Key Elements:
Data Range: A1:B7
Chart Type: Pie
Data Labels: Display both category name and value in bold, outside the end.
Pie Explosion: 5% for all slices, 27% for Slice 1.
Custom Slice Colors: Custom Hex color codes for each slice.
Legend Position: Left.
Follow the reference code below: -
• Sub CreatePieChart()
• Dim chartObj As ChartObject
• Dim dataRange As Range
• Dim pieChart As chart
• ' Define data range (A1:B7 from active sheet)
• Set dataRange = activeSheet.Range("A1:B7")
• ' Add a pie chart to the worksheet
• Set chartObj = activeSheet.ChartObjects.Add(Left:=100, Width:=400, Top:=100, Height:=300)
• ' Set chart data range
• pieChart.SetSourceData Source:=dataRange
• ' Set chart type to Pie
• pieChart.ChartType = xlPie
• ' Add data labels (Category name and value) in bold and place outside the end
• .HasDataLabels = True
• With .DataLabels
• .ShowCategoryName = True
• .ShowValue = True
• .ShowPercentage = False
• .Font.Bold = True
• .Position = xlLabelPositionOutsideEnd
• End With
• End With
• ' Set custom colors for each slice using Hex color codes
• ' Apply Pie Explosion for all slices (5%)
• ' Set explosion for Series 1 (Slice 1) to 27%
• ' Set the chart title
• pieChart.HasTitle = True
• ' Set Legend position to left
• pieChart.HasLegend = True
• pieChart.Legend.Position = xlLegendPositionLeft
• End Sub
Write effective prompts to automate pie chart creation.
Customize your chart with colors, labels, and layouts.
Save time and enhance your workflow with AI-powered solutions.
Whether you're a beginner or an Excel pro, this tutorial will help you take your skills to the next level. Subscribe to Prompt School for more smart solutions
Motto: - “Create Pie Chart In Excel”
Prompt:
I want to create a Pie Chart in Excel using VBA. Please provide the complete VBA code with the following requirements:
1. Set the data range (A1:B7) from the active sheet.
2. Include data labels showing both the category name and value.
3. Label Option: - Values Outside End, Label Contain Category Name with values. Values in Bold
4. Set custom colors for each slice (using Hex color codes).
a. Slice 1: #FF7F50, Slice 2: #DE3163, Slice 3: #6495ED, Slice 4: #FFBF00, Slice 5: #800000, Slice 6: #008080
5. Apply Pie Explosion of 5% for all slices.
6. Set explosion for Series 1 (Slice 1) to 27%.
7. Set Legend options (left position).
8. Set the chart title. Chart Title “Prompt Agent”
Key Elements:
Data Range: A1:B7
Chart Type: Pie
Data Labels: Display both category name and value in bold, outside the end.
Pie Explosion: 5% for all slices, 27% for Slice 1.
Custom Slice Colors: Custom Hex color codes for each slice.
Legend Position: Left.
Follow the reference code below: -
• Sub CreatePieChart()
• Dim chartObj As ChartObject
• Dim dataRange As Range
• Dim pieChart As chart
• ' Define data range (A1:B7 from active sheet)
• Set dataRange = activeSheet.Range("A1:B7")
• ' Add a pie chart to the worksheet
• Set chartObj = activeSheet.ChartObjects.Add(Left:=100, Width:=400, Top:=100, Height:=300)
• ' Set chart data range
• pieChart.SetSourceData Source:=dataRange
• ' Set chart type to Pie
• pieChart.ChartType = xlPie
• ' Add data labels (Category name and value) in bold and place outside the end
• .HasDataLabels = True
• With .DataLabels
• .ShowCategoryName = True
• .ShowValue = True
• .ShowPercentage = False
• .Font.Bold = True
• .Position = xlLabelPositionOutsideEnd
• End With
• End With
• ' Set custom colors for each slice using Hex color codes
• ' Apply Pie Explosion for all slices (5%)
• ' Set explosion for Series 1 (Slice 1) to 27%
• ' Set the chart title
• pieChart.HasTitle = True
• ' Set Legend position to left
• pieChart.HasLegend = True
• pieChart.Legend.Position = xlLegendPositionLeft
• End Sub