Skip to content

Instantly share code, notes, and snippets.

@Kyeongrok
Last active August 6, 2017 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kyeongrok/1b5628d73ed98d65dd055b5c3475e026 to your computer and use it in GitHub Desktop.
Save Kyeongrok/1b5628d73ed98d65dd055b5c3475e026 to your computer and use it in GitHub Desktop.
excel vba draw chart
Sub main_chart()
    '차트 지우기
    'Sheets("Sheet1").ChartObjects.Delete
    '65 -> A, 66 -> B, 67 ->c
    For  = 1 To 12
        top_1 =  * 230 - 220
        Call drawChart("Sheet2", "Sheet1!A1:A27,Sheet1!" & Chr(65 + 월) & "1:" & Chr(65 + 월) & "27", top_1)
        Call drawChart("Sheet3", "Sheet1!A1:A27,Sheet1!" & Chr(65 + 월) & "1:" & Chr(65 + 월) & "27", top_1)
    Next
End Sub
Sub drawChart(p_시트명, p_데이터범위, p_top)
    Sheets(p_시트명).Select
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlColumnClustered
    ActiveChart.SetSourceData Source:=Range(p_데이터범위)
    
    '차트 위치 이동
    ActiveChart.Parent.Top = p_top
    ActiveChart.Parent.Left = 100
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment