How to rotate labels? VBA Chart Excel

Hi everyone, can I ask how can I rotate the label of this chart using VBA?

Thank you.

This is my codes:

Private Sub OptionButton1_Click()
ActiveSheet.Range("F2").Select
Dim wks As Worksheet
For Each wks In Worksheets
    If wks.ChartObjects.Count > 0 Then
       wks.ChartObjects.Delete
    End If
Next wks

Dim rng As Range
Dim cht As ChartObject
Set rng = ActiveWorkbook.Sheets("REPORT DATA").Range("D2:AI10")
  Set cht = ActiveSheet.ChartObjects.Add( _
    Left:=ActiveCell.Left, _
    Width:=1180, _
    Top:=ActiveCell.Top, _
    Height:=548)
  If Range("I38") >= Range("K38") Then
  MsgBox "Wrong date value, please check your enrty.", vbCritical, "Error"
  Else
  cht.Chart.SetSourceData Source:=rng
  cht.Chart.ChartType = xlXYScatterLines
  cht.Chart.SetElement (msoElementDataLabelCenter)
  cht.Chart.ChartArea.Format.TextFrame2.TextRange.Font.size = 8
  cht.Chart.HasTitle = True
  cht.Chart.ChartTitle.Text = "LEONARDO - MounterTrace Size with Index Line 1 to 8"
  cht.Chart.Axes(xlCategory).MinimumScale = Range("I38")
  cht.Chart.Axes(xlCategory).MaximumScale = Range("K38")
  cht.Chart.ChartArea.Format.Fill.Visible = msoFalse
  cht.Chart.PlotArea.Format.Fill.Visible = msoFalse
  End If
End Sub

Open in new window


SampleDatabase-Monitoring-Size-January-20.xlsm
Rowel VirgoVisual Studio .NETAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
try add this piece of codes:

Dim ser As Series, pt As Point
        For Each ser In cht.Chart.SeriesCollection
            For Each pt In ser.Points
                pt.DataLabel.Orientation = xlUpward
            Next
        Next

Open in new window


DataLabel.Orientation Property (Excel)
https://msdn.microsoft.com/en-us/vba/excel-vba/articles/datalabel-orientation-property-excel

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rowel VirgoVisual Studio .NETAuthor Commented:
Already added to my file. Thanks it works...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.