Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 717
Adrian Avatar asked Oct 22 '12 09:10

Adrian


People also ask

How do you change the background of an Excel sheet?

Click the worksheet that you want to display with a sheet background. Make sure that only one worksheet is selected. On the Page Layout tab, in the Page Setup group, click Background. Select the picture that you want to use for the sheet background, and then click Insert.


1 Answers

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.

like image 139
Jook Avatar answered Oct 04 '22 02:10

Jook