VBA Formatting Cells

You can use macro in formatting cells, which involves using the Range Properties discussed earlier on. There are many properties we can use to edit cells, such as the cell size (the height, the width), cell color, font etc.

As an example, we will change the cell color to green if the inputted value is a number and bring a Notification if otherwise. Then also change the font of the cell.

Now, open another Editor window and add the following macros to the ones written in the previous example:

Fig 2.5 Macro for formatting cells
Fig 2.6 Macros for formatting, selecting, and populating selected cells

Some simple programming and VBA concepts were used in the macros above. Stuffs like IsNumeric; which checks if our input value is a number (Numeric). It is a method in Excel (it performs an action). Also, the “If End If” is a conditional statement and it is a programming concept to check the condition of a statement.

Leave a Reply

RAND Function

The Excel RAND function returns a random number between 0 and 1. This is a rather simple function in Excel,

Read More »


The CUMPRINC Function in Excel returns the cumulative principal paid on a loan between the start and end period. This

Read More »
Scroll to Top