Register now or log in to join your professional community.
Please Try this code....
Sub AddChartValues()On Error GoTo Err1Dim i, k As Integerk = InputBox("Enter the number of the Series") Range("A1") = "Titles" Range("B1") = "Values" For i =1 To k Range("A" & i +1) = InputBox("Enter the title Number " & i) Range("B" & i +1) = InputBox("Enter the Value " & i) Next i ''''''' ActiveSheet.Shapes.AddChart.Select ActiveChart.ChartType = xl3DColumnStacked ActiveChart.SetSourceData Source:=Range("A1:b" & i) ActiveChart.SeriesCollection(1).ChartType = xlColumnClustered ActiveChart.SeriesCollection(1).Trendlines.Add ActiveChart.SeriesCollection(1).Trendlines(1).Select With Selection .Type = xlPolynomial .Order =6 End With ActiveChart.Legend.Select ActiveChart.Legend.LegendEntries(2).Select Selection.Delete Exit SubErr1: End Sub