If you want to remove gridlines from the chart. Try this macro
Sub remove_gridlines()
Dim cht As Chart
Dim axs As Axis
' change chart name here
Set cht = Sheets("Sheet1").ChartObjects("Chart 3").Chart
For Each axs In cht.Axes
axs.HasMajorGridlines = False
axs.HasMinorGridlines = False
Next
End Sub
----------------------------------------------------------------------------------------------------------------------
Sub remove_specific_gridline()
Dim cht As Chart
'change chart name here
Set cht = Sheets("Sheet1").ChartObjects("Chart 3").Chart
With cht.Axes(xlCategory, xlPrimary)
'Hide Minor Gridline only
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
With cht.Axes(xlValue, xlPrimary)
'Hide both
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
End Sub
Sub remove_gridlines()
Dim cht As Chart
Dim axs As Axis
' change chart name here
Set cht = Sheets("Sheet1").ChartObjects("Chart 3").Chart
For Each axs In cht.Axes
axs.HasMajorGridlines = False
axs.HasMinorGridlines = False
Next
End Sub
----------------------------------------------------------------------------------------------------------------------
Sub remove_specific_gridline()
Dim cht As Chart
'change chart name here
Set cht = Sheets("Sheet1").ChartObjects("Chart 3").Chart
With cht.Axes(xlCategory, xlPrimary)
'Hide Minor Gridline only
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
With cht.Axes(xlValue, xlPrimary)
'Hide both
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
End Sub
No comments:
Post a Comment