Name

window.GridlineColor [= setting]

Synopsis

Sets or returns the color of gridlines as an RGB color. RGB colors are long integers that you can create using the RGB function or (commonly) by specifying a value in hexadecimal. The following code changes the grid color to red, green, blue, and back to normal:

Sub TestGridlineColor(  )
    ' Change grid color using hexidecimal values.
    ActiveWindow.GridlineColor = &HFF     ' Red
    ' Wait 1 second.
    API.Sleep (1000)
    ActiveWindow.GridlineColor = &HFF00   ' Green
    API.Sleep (1000)
    ActiveWindow.GridlineColor = &HFF0000 ' Blue
    API.Sleep (1000)
    ' Restore the default.
    ActiveWindow.GridlineColorIndex = xlColorIndexAutomatic
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.