Avatar of Rowel Virgo
Rowel VirgoFlag for Philippines

asked on 

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


User generated imageDatabase-Monitoring-Size-January-20.xlsm
ProgrammingVBAProgramming Languages-OtherMicrosoft Excel

Avatar of undefined
Last Comment
Rowel Virgo
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Rowel Virgo
Rowel Virgo
Flag of Philippines image

ASKER

Already added to my file. Thanks it works...
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo