Replace the original code in the userform with this
Code:Private Sub CommandButton1_Click() Dim lng As Long Dim ser As Series For lng = 0 To Me.ListBox1.ListCount - 1 If Me.ListBox1.Selected(lng) Then With Worksheets("Charts") With .Shapes.AddChart.Chart .Parent.Top = Worksheets("Charts").ChartObjects.Count * .Parent.Height + 10 - .Parent.Height .ChartType = xlColumnClustered .SetSourceData Source:=Worksheets("DATA").Range("" & Worksheets("DATA").Range(Replace(Me.ListBox1.List(lng), "-", "")).Address & "," & Worksheets("DATA").Range(Replace(Me.ListBox1.List(lng), "-", "")).Offset(, Me.ComboBox1.ListIndex + 1).Address) .Parent.Width = .Parent.Width * 2 .ChartGroups(1).GapWidth = 50 .ApplyDataLabels For Each ser In .SeriesCollection With ser.DataLabels .ShowSeriesName = True .Position = xlLabelPositionInsideBase .Separator = "" & Chr(10) & "" End With Next ser End With End With End If Next lng Application.Goto Worksheets("Charts").Range("A1") Unload Me End Sub




Reply With Quote
Bookmarks