Excel VBA: Simple Bill Generator For Beginners
🗓️ Published on January 11, 2023 • ⚡ 2 min read
If you are completely new to Excel Macros (VBA), this easy guide will help you create your very first automatic customer billing sheet in under two minutes!
Step 1: Set Up Your Excel Sheet
Open a blank Excel sheet and type these exact labels into Column A and Column B:
| Cell Location | What to Type |
|---|---|
| Cell A1 | Customer Name |
| Cell A2 | Item Quantity |
| Cell A3 | Price Per Item |
| Cell A5 | TOTAL BILL AMOUNT |
Step 2: Copy the VBA Code
Copy this beginner-friendly code block below:
Sub MakeEasyBill()
' 1. Read values entered by the user
Dim Qty As Double
Dim Price As Double
Qty = Range("B2").Value
Price = Range("B3").Value
' 2. Calculate the total and put it in cell B5
Range("B5").Value = Qty * Price
' 3. Show a pop-up alert box
MsgBox "Bill calculated successfully!", vbInformation, "Done"
End Sub
Step 3: How to Paste and Run the Code
- Inside your Excel file, press ALT + F11 together. This opens the blank programming window.
- Click Insert in the top menu bar, then click Module.
- Paste the code you copied above into the blank white screen that pops up.
- Close that window to go back to your Excel sheet.
🎉 The Final Result You Will See
Type any number into B2 (like 5) and B3 (like 10). Press ALT + F8, select MakeEasyBill, and click Run.
[Pop-up Alert Box]: "Bill calculated successfully!"
Cell B5 will instantly turn into 50!