ich habe folgendes problem, ich habe mir ein makro erstellt mit dem makro recorder das mir aus einer excel datei xy 4 verschiedene diagramme generiert.
Soweit läuft auch alles.
Nun möchte ich dieses makro aber auch auf andere Dateien anwenden , also Dateien die zwar strukturell gleich sind , aber einen anderen dateinamen besitzen.
Ansich einfach die statischen dateinamen werte durch variable ersetzen , nur wie ;)
Vielen dank schonmal für die Hilfe
Max
Source:
Sub Makro1()
' Makro1 Makro
Range("A17:H27").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("warnstufen_gesamt_n2").Range( _
"A17:H17,A19:H27"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="trigger_d"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Nur Trigger"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = _
"Eigengeschwindigkeit km/h"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Häufigkeit"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlTop
Sheets("warnstufen_gesamt_n2").Select
Range("I33,A17:H17,A30:H38,I33").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("warnstufen_gesamt_n2").Range( _
"A17:H17,A30:H38"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="now_d"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "NOW"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = _
"Eigengeschwindigkeit km/h"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Häufigkeit"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlTop
ActiveChart.HasDataTable = False
Sheets("warnstufen_gesamt_n2").Select
Range("A17:H17").Select
ActiveWindow.SmallScroll Down:=12
Range("A41:H49").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("warnstufen_gesamt_n2").Range( _
"A17:H17,A41:H49"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="aw_d"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "AW"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = _
"Eigengeschwindigkeit km/h"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Häufigkeit"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlTop
ActiveChart.HasDataTable = False
Sheets("warnstufen_gesamt_n2").Select
ActiveWindow.SmallScroll Down:=3
Range("A17:H17").Select
ActiveWindow.SmallScroll Down:=15
Range("A17:H17,A52:H60").Select
Range("A52").Activate
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("warnstufen_gesamt_n2").Range( _
"A17:H17,A52:H60"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="wb_d"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "WB"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = _
"Eigengeschwindigkeit km/h"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Häufigkeit"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlTop
ActiveChart.HasDataTable = False
Sheets("warnstufen_gesamt_n2").Select
ActiveWindow.SmallScroll Down:=-3
Range("A17:H17").Select
ActiveWindow.SmallScroll Down:=27
Range("A17:H17,A63:H71").Select
Range("A63").Activate
ActiveWindow.SmallScroll Down:=-27
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("warnstufen_gesamt_n2").Range( _
"A17:H17,A63:H71"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="nb_d"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "NB"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = _
"Eigengeschwindigkeit km/h"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Häufigkeit"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlTop
Sheets("warnstufen_gesamt_n2").Select
End Sub