Search code examples
excelvbabackground-color

Change Background Color for Entire Sheet


Is there a way to change the Background color into xlNone, for example to the entire sheet. I see that you can put a background image... But how can you change the color for all cells in the sheet?


Solution

  • You can do this quite easy with this code:

    Public Sub Demo()
      'set color
      WorksheetName.Cells.Interior.ColorIndex = 1 'black
      'clear color
      WorksheetName.Cells.Interior.ColorIndex = xlColorIndexNone
    end sub
    

    Or if you don't need VBA, just click at this little icon in the corner:

    enter image description here

    and select a color, or to use no color - using right click menu or ribbon menu.

    Just because of the other answers, I want to remind - it is not necessary to use selections! This is bad macro-recorder style. There are only few occations, where using selections is necessary or a good idea. You can always just use a specific range.