How to use Accounting Number Format through VBA Formatting?
Tags: touseaccountingnumbe, vbamacros
Published: 2021-09-29 09:13:16

---
title: How to use Accounting Number Format through VBA Formatting?
published: true
date: 2021-09-26 05:41:10 UTC
tags: ToUseAccountingNumbe,VBAMacros
canonical_url: https://geekexcel.com/how-to-use-accounting-number-format-through-vba-formatting/
---

In this post, we will explain to you how to **use accounting number format** through VBA formatting in Excel VBA. Let’s see them below!! Get an official version of MS Excel from the following link: **[https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)**

## Example

- Firstly, you have to **create a sample data** with **product’s amount data in range A1:B9,** in which **column A** contains **Product name** and **column B** contains **amount**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Sample-data-29.png)<figcaption>Sample data</figcaption>

- In the Excel Worksheet, you have to go to the  **Developer Tab.**
- Then, you need to ** ** select the  **Visual Basic**  option under the  **Code**  section.

![Select Visual Basic](https://geekexcel.com/wp-content/uploads/2021/09/Select-Visual-Basic-9-1024x180.png)<figcaption>Select Visual Basic</figcaption>

- Now, you have to click on  **Insert** , and then select  **Module**.

![Insert a module](https://geekexcel.com/wp-content/uploads/2021/09/Insert-a-module.png)<figcaption>Insert a module</figcaption>

- Now, you have to  **copy and paste the code**  given below.

```
Sub FormatAccounting()
Dim Sh As Worksheet
Set Sh = ThisWorkbook.Sheets(1)
Sh.Range("B2:B9").NumberFormat = "_($*#,##0.00_);_($*(#,##0.00);_($*""_""??_);_(@_)"
End Sub

```

- You need to  **save the code**  by selecting it and then  **close the window**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Save-the-Code-65-1024x298.png)<figcaption>Save the Code</figcaption>

- Again, you have to go to the  **Excel Spreadsheet** , and click on the  **Developer Tab**.
- You need to choose the  **Macros option**  in the Code section.

![Choose Macro option](https://geekexcel.com/wp-content/uploads/2021/09/Choose-Macro-option-11-1024x184.png)<figcaption>Choose Macro option</figcaption>

- Now, you have to make sure that your  **macro name is selected**  and click the  **Run ** button.

![](https://geekexcel.com/wp-content/uploads/2021/09/Run-the-Code-38.png)<figcaption>Run the Code</figcaption>

- Finally, you will receive the  **output ** as in Microsoft Excel.

![](https://geekexcel.com/wp-content/uploads/2021/09/Output-30.png)<figcaption>Output</figcaption>

## Wrap-Up

Hope you understood how to **use accounting number format** through VBA formatting in Excel VBA. Please feel free to state your query or feedback for the above article. Thank you for Reading!! To learn more, check out **[Geek Excel](https://geekexcel.com/)!! **and [**Excel Formulas**](https://geekexcel.com/excel-formula/) **!!**

**Read Ahead:**

- **[How to Format Cells in Microsoft Excel 2007?](https://geekexcel.com/how-to-format-cells-in-microsoft-excel-2007/)**
- **[How to Clear All Formatting of a Range in Excel Office 365?](https://geekexcel.com/how-to-clear-all-formatting-of-a-range-in-excel-office-365/)**
- **[How to Change the Date Format in Excel Office 365? ~ Complete Guide!!](https://geekexcel.com/change-date-format-in-excel/)**
- **[Excel Formulas to Apply Conditional Formatting based on Another Cell!!](https://geekexcel.com/excel-formulas-to-apply-conditional-formatting-based-on-another-cell/)**
- **[how to Create Charts with excel VBA? ~ Quick Steps!!](https://geekexcel.com/how-to-create-charts-with-excel-vba-quick-steps/)**