티스토리 뷰

카테고리 없음

[Excel][VBA] 차트 서식변경

어린왕자1234 2021. 11. 26. 16:36

■ 차트서식 넣기

Sub FormatAChart()
    If ActiveChart Is Nothing Then
        MsgBox "Activate a chart"
        Exit Sub
    End If
    With ActiveChart
        .ChartType = xlColumnClustered
        .ApplyLayout 10   
        .ChartStyle = 30
        .SetElement msoElementPrimaryValueGridLinesNone
        .ClearToMatchStyle
    End With
End Sub

▶ ChartType  : 차트 종류 지정
▶ ApplyLayout : 차트도구>디자인>차트 레이아웃  ' ApplyLayout 10, xlColumnClustered 로 차트 종류 함께 지정
▶ ChartStyle : 차트도구>디자인>차트 스타일
▶ SetElement : 구성요소 표시 여부
▶ ClearToMatchStyle : 모든 사용자 지정 서식 제거

 

 

■ 그림자 효과 넣기

Chart에 Title에
Sub FormatAChart()
    With ActiveChart.ChartArea.Format.Shadow
        .Visible = msoTrue
        .Blur = 10
        .Transparency = 0.4
        .OffsetX = 6
        .OffsetY = 6
    End With
        
End Sub

Sub FormatAChart()
    ActiveChart.ChartTitle.Format.Fill.BackColor.RGB = RGB(255, 255, 255)
    With ActiveChart.ChartTitle.Format.Shadow
        .Visible = msoTrue
        .Blur = 3
        .Transparency = 0.3
        .OffsetX = 2
        .OffsetY = 2
    End With
        
End Sub

 

■ 3D 효과 넣기

Sub FormatAChart()
    
    With ActiveChart.ChartArea.Format.ThreeD
        .Visible = msoTrue
        .BevelTopType = msoBevelDivot
        .BevelTopDepth = 12
        .BevelTopInset = 32
    End With
        
End Sub