AW: Blasendiagramme hinzufügen / VBA
10.07.2012 16:33:43
Hajo_Zi
Hi Peter,
mit dem Code wird geprüft, welche Projekte bereits im Diagramm eingetragen sind - nicht vorhandene werden ergänzt. Es spielt also keine Rolle, wann der Code ausgeführt wird - sofort nach Ergänzung eines neuen Projektes im Tabellenblatt oder nachdem mehrere Projekte eingetragen wurden.
Sub DiaErgaenzen()
Dim iSpalte As Integer
Dim lZeile As Long
Dim intReihe As Integer
Dim blnVorhanden As Boolean
Rows("1:500").EntireRow.Hidden = False
iSpalte = 6
For lZeile = 1 To Cells(Rows.Count, iSpalte).End(xlUp).Row
If Cells(lZeile, iSpalte) = "closed" Then
Rows(lZeile).EntireRow.Hidden = True
End If
Next lZeile
For lZeile = 12 To IIf(IsEmpty(Cells(Rows.Count, 3)), Cells(Rows.Count, 3).End(xlUp).Row, _
Rows.Count)
With ActiveSheet.ChartObjects(1).Chart
For intReihe = 1 To .SeriesCollection.Count
If .SeriesCollection(intReihe).Name = Cells(lZeile, 3) Then
blnVorhanden = True
Exit For
End If
Next intReihe
If blnVorhanden = False Then
With .SeriesCollection.NewSeries
.Name = Cells(lZeile, 3)
.XValues = Cells(lZeile, 4)
.Values = Cells(lZeile, 5)
.BubbleSizes = Cells(lZeile, 7)
.ApplyDataLabels
With .DataLabels
.ShowSeriesName = True
.ShowValue = False
.Position = xlLabelPositionCenter
With .Format.Fill
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0.5
.Solid
End With
End With
End With
End If
End With
blnVorhanden = False
Next lZeile
End Sub