First foray into VBA Created charts and I'm losing my mind. I have a macro that creates a chart based on the data that is selected in a listbox userform. I wanted to name the chart based on a string variable that I set through the user form but I can't even get name it anything right now. I've attached the first half of the macro code, the last line is where I am erroring.
Sub Y_Print_Chart()
If WorksheetExists("Scenario Charts", ActiveWorkbook) Then
Sheets("Scenario Charts").Select
Else
Sheets.Add.Name = "Scenario Charts"
Sheets("Scenario Charts").Select
Range("A1").Select
ActiveCell = ActiveCell.Value + 1
With ActiveWorkbook.Sheets("Scenario Charts").Tab
.Color = 255
.TintAndShade = 0
End With
End If
Sheets("Scenario Charts").Move After:=Sheets("Scenario Planning")
Dim chartit As String
Dim demand As Integer
Dim prod As Integer
Dim doh As Integer
Dim cell As Range
Dim multiply As Integer
Sheets("Scenario Planning").Select
chartit = Range("A1").Value
Range("A2").Select
If chartit = ActiveCell.Value Then
Set cell = Range("C11")
Else
Range("B1").Select
Do Until chartit = ActiveCell.Value
If chartit = ActiveCell.Value Then
ActiveCell.Offset(1, 0).Select
Set cell = ActiveCell
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End If
cell.Select
demand = ActiveCell.row
prod = ActiveCell.row + 1
doh = ActiveCell.row + 3
Sheets("Scenario Charts").Select
Range("A1").Select
multiply = multiply * ActiveCell.Value
ActiveCell.Offset(multiply, 0).Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
ActiveChart.Name = "Chart"
I want to say ActiveChart.Name = "" & chartit & "" in a perfect world because that would give each chart a unique name based on its data set. Help?
Bookmarks