AW: Nein. (owT)
16.10.2017 15:08:24
Bernd
Hallo Nepumuk,
Werkzeugsammlung durch Chart-Tool ergänzt!
Hier mein Code, den ich benutze um ein Chart in einer Tabelle abzulegen, nützt dir das etwas? Ansonsten müsste ich eine Mustermappe basteln.
Gruß Bernd
Sub Chart1J_erstellen_Depot()
Dim startzeile As Integer 'Dim lngRow As Long
On Error GoTo Fehler
startzeile = InputBox("Wählen Sie die Zeilen-Nr. ihrer Aktie!") 'lngRow = startzeile
Application.ScreenUpdating = False
With Worksheets("Depot")
If .Cells(startzeile, 7).Value = "" Or Not wksExits1(.Cells(startzeile, 7).Value) Then
MsgBox "Fehler, bitte prüfen Sie ob Kurstabellen vorhanden sind?", vbExclamation
Exit Sub
End If
End With
Sheets("Chart-Vorschau").Visible = True
With Charts.Add
.ChartType = xlLine
.SetSourceData Source:=Sheets(Worksheets("Depot").Cells(startzeile, 7).Value).Range("B2: _
B258,G2:G258")
.Location Where:=xlLocationAsObject, Name:="Chart-Vorschau"
End With
With ActiveSheet.ChartObjects(1)
.Left = 2
.Top = 2
.Width = 1260
.Height = 700
End With
With ActiveChart
.HasTitle = True
.ChartTitle.Text = "Indizes:" & " " & Sheets("Depot").Cells(startzeile, 5).Value & " " & _
" - Titel:" & " " & Sheets("Depot").Cells(startzeile, 1).Value _
& " " & " - ISIN:" & " " & Sheets("Depot").Cells(startzeile, 8).Value & " - Kursverlauf ü _
ber 1 Jahr - mit 30, 90 und 200 Tage Trendlinien"
.ChartArea.Select
.Legend.Select
Selection.Position = xlTop
.Axes(xlCategory).MajorUnitScale = xlDays
.Axes(xlCategory).MajorUnit = 6
.Axes(xlCategory).HasMajorGridlines = True
.Axes(xlValue).MinimumScale = WorksheetFunction.Small(Sheets(Worksheets("Depot").Cells( _
startzeile, 7).Value).Range("G2:G258"), 1)
End With
Application.ScreenUpdating = True
Call trend_30_90_200Depot
Exit Sub
Fehler:
MsgBox "Ein Fehler ist aufgetreten, da die Angaben falsch waren! Bitte starten Sie die _
Abfrage neu!"
End Sub
Und der zweite Code:
Sub trend_30_90_200()
ActiveChart.SeriesCollection(1).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 102, 153)
End With
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
End With
With Selection.Format.Line
.Visible = msoTrue
.Weight = 1
End With
ActiveChart.SeriesCollection(1).Trendlines.Add
ActiveChart.SeriesCollection(1).Trendlines(1).Select
With Selection
.Type = xlMovingAvg
.Period = 2
End With
With Selection
.Type = xlMovingAvg
.Period = 30
End With
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
End With
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(51, 204, 51)
.Transparency = 0
End With
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Trendlines.Add
ActiveChart.SeriesCollection(1).Trendlines(2).Select
With Selection
.Type = xlMovingAvg
.Period = 2
End With
With Selection
.Type = xlMovingAvg
.Period = 90
End With
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(51, 204, 51)
End With
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 255)
.Transparency = 0
End With
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Trendlines.Add
ActiveChart.SeriesCollection(1).Trendlines(3).Select
With Selection
.Type = xlMovingAvg
.Period = 2
End With
With Selection
.Type = xlMovingAvg
.Period = 200
End With
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 255)
End With
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
End With
End Sub