Format Percentages in VBA

When we apply the percentage number format to cells with values, the values are multiplied by 100 to convert them to percentages. This tutorial shows how to format percentages in Excel VBA.

We will apply the percentage number format to range D2:D4 in the following dataset to display the numbers as percentages, not decimals.

We use the following steps:

  1. Click Developer >> Code >> Visual Basic to open the Visual Basic Editor.

You can also press Alt + F11 to open the Visual Basic Editor.

  1. In the Visual Basic Editor, open the Insert menu and click the Module option to insert a module.
  1. Type the following sub-procedure in the module:
  1. Save the procedure and save the workbook as a Macro-Enabled Workbook.
  2. Click inside the procedure and press F5 to run the code. You can also run the code by clicking the Run Sub/Userform button on the toolbar.
  1. Click the View Microsoft Excel button on the toolbar to switch to the active worksheet containing the dataset.
Graphical user interface, application, Word

Description automatically generated

You can also press Alt + F11 to switch to the active worksheet.

The values in range D2:D4 of the dataset are displayed as percentages.

Table, Excel

Description automatically generated

Conclusion

This tutorial has explained how to format percentages in Excel VBA. We hope you found the information helpful.

Tomasz Decker is an Excel specialist, skilled in data analysis and financial modeling.

Posted in vba