Tuesday, September 13, 2022
HomeOperating SystemChange Cell Background Colour in Excel with VBA Editor

Change Cell Background Colour in Excel with VBA Editor


Microsoft Excel is a program that’s used worldwide by many individuals to do calculations and retailer information, however do you know that you would be able to change the cell background with VBA Editor in Excel as a substitute of utilizing the Fill shade function or the Conditional Formatting function? You may sort codes in VBA Editor to change the cell colours in Excel.

Change Cell Background Color in Excel with VBA Editor

Change Cell Background Colour in Excel with VBA Editor

To alter the cell background with VBA Editor in Excel observe these steps:

  1. Launch Microsoft Excel.
  2. Click on the Developer tab, then click on the Visible Primary button.
  3. As soon as the VBA Editor is open, sort the code to alter the colour of the cell.
  4. Then click on the Run button and choose Run Sub/UserForm.
  5. Shut the VBA Editor and take a look at the spreadsheet to see the outcomes.

Launch Microsoft Excel.

On the Developer tab, click on the Visible Primary button.

The VBA Editor will open.

Within the VBA Editor, sort the next under:

Sub Standard_Color()

Vary(“A1”).Inside.Colour = vbGreen

Vary(“b3”).Inside.Colour = vbBlue

Finish Sub

Then click on the Run button and choose Run Sub/UserForm.

Shut the VBA editor then you will notice the colours within the cell you’ve written within the code.

How do I take away cell shade in Excel VBA?

  • On the Developer tab, click on the Visible Primary button.
  • The VBA Editor will open.
  • Within the VBA Editor, sort the next under:
  • Sub Standard_Color()
  • Vary(“A1”).Delete
  • Finish Sub
  • Now click on the Run button and choose Run Sub/UserForm.

Shut the VBA Editor and take a look at your spreadsheet; you’ll discover that the colour is cleared from the cell.

How do I make a macro clear a cell?

Comply with the steps under on find out how to use a macro to clear a cell in Excel:

  • On the Developer tab, click on Macros.
  • A Macro dialog field will open.
  • Kind a reputation within the identify field, then click on Create.
  • This can open the VBA Editor
  • Kind the next Codes under:
  • Sub Clear Cells()
  • Vary(“b3:b4”).ClearContents
  • Finish Sub
  • Now click on the Run button and choose Run Sub/UserForm.

Shut the VBA Editor and take a look at your spreadsheet; you’ll discover that the cell is cleared.

How do I add a background to a cell in Excel?

  • Launch Microsoft Excel.
  • On the Web page Format tab within the Web page Setup group, click on the Background button.
  • An Insert image dialog field will open. Select if you wish to choose an image from File, Bing Picture Search, or OneDrive Private.
  • Select an image from any of the sources talked about above and click on Insert.
  • Now we have now a background within the spreadsheet.

What Colour codes does VBA use?

The colour codes utilized in VBA are VBA or RGB. RGB may also be known as Crimson, Inexperienced, and Blue. Many Excel customers use the RGB codes to enter shade into their spreadsheet’s cells or fonts. They’ve three elements as a named vary; these are Crimson, Inexperienced, and Blue.

READThe best way to create Customized Excel Capabilities utilizing VBA

What are the colour codes for Excel?

Have a look at the record under for the colour codes in Excel:

  • White: RGB(255,255,255)
  • Black: RGB(0,0,0)
  • Crimson: RGB(255,0,0)
  • Inexperienced: RGB (0,255,0)
  • Blue: RGB(0,0,255)
  • Yellow: RGB(255,255,0)
  • Magenta: RGB(255,0,255)
  • Cyan RGB(0,255,255)

READThe best way to create a Chart with Crayon impact in Excel

We hope you perceive utilizing the cell background with VBA Editor in Excel.

Change Cell Background Color in Excel with VBA Editor

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments