Excel Achsenbeschriftung funktioniert nicht mit VBA
#1
Also ich habe mir mit dem Rekorder folgenden Code Aufgezeichnet:


Code:
Sub ratio_diagram_norm_no()
'
' ratio_diagram_norm_no Makro
' Diagram which plottes the ratio of the diagrams in collum E accrording to the appearnce in the normal simulation
'

'
    Columns("E:E").Select
    ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
    ActiveChart.SetSourceData Source:=Range("Tabelle1!$E:$E")
    ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
    ActiveChart.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
    ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "omega_stiff/omega_norm"
    Selection.Format.TextFrame2.TextRange.Characters.Text = _
        "omega_stiff/omega_norm"
    With Selection.Format.TextFrame2.TextRange.Characters(1, 22).ParagraphFormat
        .TextDirection = msoTextDirectionLeftToRight
        .Alignment = msoAlignCenter
    End With
    With Selection.Format.TextFrame2.TextRange.Characters(1, 22).Font
        .BaselineOffset = 0
        .Bold = msoFalse
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(89, 89, 89)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 10
        .Italic = msoFalse
        .Kerning = 12
        .Name = "+mn-lt"
        .UnderlineStyle = msoNoUnderline
        .Strike = msoNoStrike
    End With
    ActiveChart.Axes(xlCategory).AxisTitle.Select
    ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "No of mode"
    Selection.Format.TextFrame2.TextRange.Characters.Text = "No of mode"
    With Selection.Format.TextFrame2.TextRange.Characters(1, 10).ParagraphFormat
        .TextDirection = msoTextDirectionLeftToRight
        .Alignment = msoAlignCenter
    End With
    With Selection.Format.TextFrame2.TextRange.Characters(1, 10).Font
        .BaselineOffset = 0
        .Bold = msoFalse
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(89, 89, 89)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 10
        .Italic = msoFalse
        .Kerning = 12
        .Name = "+mn-lt"
        .UnderlineStyle = msoNoUnderline
        .Strike = msoNoStrike
    End With
    Range("G21").Select
    Application.CommandBars("Format Object").Visible = False
    ActiveSheet.ChartObjects("Diagramm 2").Activate
    ActiveSheet.Shapes("Diagramm 2").IncrementLeft 393
    ActiveSheet.Shapes("Diagramm 2").IncrementTop -66
End Sub


Jetzt hat er aber bei     ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "omega_stiff/omega_norm" ein Problem und will das anscheinend nicht ausführen. Kann mir jemand sagen wie ich das ändern muss. Thx
Top
#2
Also die Antwort habe ich hier gefunden.

Code:
Sub ratio_diagram_norm_no()
'
' ratio_diagram_norm_no Makro
' Diagram which plottes the ratio of the diagrams in collum E accrording to the appearnce in the normal simulation
'

'
   Columns("E:E").Select
   ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
   ActiveChart.SetSourceData Source:=Range("Tabelle1!$E:$E")
   ActiveChart.ChartTitle.Text = "Frequency ratio"
   ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
   ActiveChart.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
With ActiveChart
   .Axes(xlCategory, xlPrimary).HasTitle = True
   .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "No of mode"
   .Axes(xlValue, xlPrimary).HasTitle = True
   .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "omega_stiff/omega_norm"
End With
   Range("G21").Select
   Application.CommandBars("Format Object").Visible = False
   ActiveSheet.ChartObjects("Diagramm 2").Activate
   ActiveSheet.Shapes("Diagramm 2").IncrementLeft 393
   ActiveSheet.Shapes("Diagramm 2").IncrementTop -66
End Sub
Top


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste