Sub drawChart(p_시트명, p_범위, chartTitle, tickLabelSpacing)
'On Error Resume Next
Sheets(p_시트명).Select
If Sheets(p_시트명).ChartObjects.Count > 0 Then
Sheets(p_시트명).ChartObjects.Delete
End If
'2007은 12.0 365 는 16.0
If Application.Version > 12 Then
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
Else
ActiveSheet.Shapes.AddChart(201, xlColumnClustered).Select
End If
ActiveChart.SetSourceData Source:=Range(p_범위)
Call 차트_설정변경(p_시트명, chartTitle, tickLabelSpacing)
'ActiveChart.Axes(xlValue, xlSecondary).minimumScale = 7000
End Sub
Public Sub 차트_설정변경(p_시트명, chartTitle, tickLabelSpacing)
Worksheets(p_시트명).ChartObjects(1).Activate
'차트 설정
With ActiveChart.SeriesCollection(1)
.ChartType = xlLine
.AxisGroup = 2
.Format.Line.ForeColor.RGB = RGB(52, 148, 186)
.Format.Line.Transparency = 0
End With
With ActiveChart.SeriesCollection(2)
.Interior.Color = RGB(128, 128, 128)
.ChartType = xlColumnClustered
.AxisGroup = 1
End With
ActiveChart.Axes(xlValue, xlPrimary).HasTitle = True
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "(천톤)"
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Font.Name = "맑은 고딕"
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Font.Size = 12
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Orientation = xlHorizontal
ActiveChart.Axes(xlValue, xlPrimary).TickLabels.Font.Name = "맑은 고딕"
ActiveChart.Axes(xlValue, xlPrimary).TickLabels.Font.Size = 14
ActiveChart.Axes(xlValue, xlSecondary).HasTitle = True
ActiveChart.Axes(xlValue, xlSecondary).AxisTitle.Text = "(원)"
ActiveChart.Axes(xlValue, xlSecondary).AxisTitle.Font.Name = "맑은 고딕"
ActiveChart.Axes(xlValue, xlSecondary).AxisTitle.Font.Size = 12
ActiveChart.Axes(xlValue, xlSecondary).AxisTitle.Orientation = xlHorizontal
ActiveChart.Axes(xlValue, xlSecondary).TickLabels.Font.Name = "맑은 고딕"
ActiveChart.Axes(xlValue, xlSecondary).TickLabels.Font.Size = 14
'차트 크기 위치
ActiveChart.Parent.Height = 430
ActiveChart.Parent.Width = 968
ActiveChart.Parent.Top = 55
ActiveChart.Parent.Left = 53
'카테고리 형식 문자열
ActiveChart.Axes(xlCategory).CategoryType = xlCategoryScale
'x축 데이터 간격
ActiveChart.Axes(xlCategory).tickLabelSpacing = tickLabelSpacing
ActiveChart.Axes(xlCategory).TickLabels.Font.Name = "맑은 고딕"
ActiveChart.Axes(xlCategory).TickLabels.Font.Size = 11
ActiveChart.Axes(xlCategory).TickLabels.NumberFormatLocal = "yyyy/mm/dd" '날짜 표시형식 yyyy/MM/dd
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveChart.chartTitle.Text = chartTitle
'ActiveChart.chartTitle.Font.Name = "맑은 고딕"
ActiveChart.chartTitle.Font.Size = 18
'축 제목 위치
With ActiveChart.Axes(xlValue).AxisTitle
.Left = 55
.Top = 16
End With
With ActiveChart.Axes(xlValue, xlSecondary).AxisTitle
.Left = 890
.Top = 16
End With
End Sub
```.vb
Created
November 8, 2017 13:52
-
-
Save Kyeongrok/5756d16a1ad222195f8b739807bdab3a to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment