Saturday, November 16, 2013

Check if there are charts on a given worksheet and if yes, delete them(VBA-Excel)


'This code checks if there are any charts on a specific sheet and, if yes, deletes them:

Sub know_if_there_are_charts()
Dim ws As Worksheet

If ws.ChartObjects.Count <> 0 Then
ws.ChartObjects.Delete

End If

End Sub

Divide the axis values by 1000 (VBA-Excel)


This code changes the unit of a given axis of a chart to thousand, i.e. divide the units by 1000

Sub Divide_axis_values_by_1000()
    ActiveChart.Axes(xlValue).DisplayUnit = xlThousands
End Sub