HAbe nicht wirklich Ahnung vom VBA..
Ich möchte ein Diagramm automatisch von einem bestimmten Zellenbreich erstellen lassen. Dazu soll vorher der benötigte Zellbereich ausgewählt werden. Geht das? Wenn ja, wie? (Excel2000/97)
Sub Diagramm_erstellen()
Range("A11:T17").Select
Range("T17").Activate
Charts.Add
ActiveChart.ChartType = xlColumnStacked100
ActiveChart.SetSourceData Source:=Sheets("Tabelle1").Range("A11:T17"), _
PlotBy:=xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="Tabelle1"
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom
End Sub
Sub Diagramm_erstellen()
Dim Diagr As Chart
Dim WS As Worksheet
Dim Bereich As Range
Set WS = Worksheets("Tabelle1")
Set Bereich = WS.Range("A11:T" & WS.Range("A65536").End(xlUp).Row)
Set Diagr = Charts.Add
With Diagr
.ChartType = xlColumnStacked100
.SetSourceData Source:=Bereich, PlotBy:=xlRows
.Location Where:=xlLocationAsObject, Name:=WS.Name
ActiveChart.HasLegend = True
ActiveChart.Legend.Position = xlBottom
End With
End Sub