To set a cell or range to percentage format in Excel VBA, set the NumberFormat property to "0.00%" (or "0%" for whole percentages). For example: Range("A1").NumberFormat = "0.00%". This changes only the display; the underlying value stays the same, so 0.25 shows as 25.00%.

What You'll Need

  • Excel with the Developer tab enabled (File > Options > Customize Ribbon > check Developer).
  • A workbook saved as .xlsm if you want to keep macros.
  • Basic familiarity with the VBA editor (Alt+F11).

Step-by-Step

  1. Open your workbook and press Alt+F11 to open the VBA editor.
  2. In the Project Explorer, right-click your workbook and choose Insert > Module.
  3. In the new module, type a short macro. For a single cell:
    Sub FormatPercent()
        Range("A1").NumberFormat = "0.00%"
    End Sub
  4. For a range, use Range("A1:A10").NumberFormat = "0.00%".
  5. To format the entire used range of a worksheet, use ActiveSheet.UsedRange.NumberFormat = "0.00%".
  6. Press F5 to run the macro, or close the editor and run it from the Macros dialog (Alt+F8).
  7. Check the cell: the value should now display with a percent sign. If you see 2500.00% instead of 25.00%, your cell contains 25 rather than 0.25 — see Common Mistakes.

You can also use the built-in constant xlPercent with Range("A1").NumberFormat = xlPercent, but this gives a plain 0% format. For decimal places, stick with the string "0.00%".

Common Mistakes

  • Formatting a value that is already a whole number. If A1 contains 25 and you apply "0.00%", it shows 2500.00%. Either divide the value by 100 first (Range("A1").Value = Range("A1").Value / 100) or type 0.25 into the cell.
  • Using NumberFormatLocal incorrectly. NumberFormat uses US-style codes regardless of your regional settings; NumberFormatLocal expects the local separator. Mixing them up can produce unexpected results in some locales.
  • Forgetting that formatting does not change the value. A cell showing 25% still holds 0.25. Formulas that reference it use 0.25, not 25.
  • Applying to the wrong sheet. Unqualified Range refers to the active sheet. If your macro runs while another sheet is active, it formats the wrong cells. Qualify with Worksheets("Sheet1").Range("A1").
  • Overwriting existing formats. Setting NumberFormat replaces any custom format. If you need to preserve other formatting, store and restore it, or apply only to the specific range.

Tips

  • Use "0.0%" for one decimal place, "0%" for none, and "0.00%" for two.
  • To format a whole column, use Columns("B").NumberFormat = "0.00%".
  • If you want to convert the value as well as the display, combine formatting with a calculation: Range("A1").Value = Range("A1").Value / 100: Range("A1").NumberFormat = "0.00%".
  • Use With blocks to format multiple ranges cleanly:
    With Range("A1:A10")
        .NumberFormat = "0.00%"
        .HorizontalAlignment = xlCenter
    End With
  • Test on a copy of your workbook first; number formats are easy to reapply but harder to undo if you overwrite custom formats.

Troubleshooting

If the macro runs but the cell still shows a decimal or a whole number, check that the cell is not set to Text format. A cell formatted as Text ignores number formats. Select the cell, press Ctrl+1, choose Number or General, then rerun the macro. If you see a run-time error 1004, the sheet may be protected or the range name invalid; unprotect the sheet or correct the range address. If the percent sign appears but the value is wrong by a factor of 100, you applied the format to a whole number — divide by 100 as described above. If nothing happens at all, make sure macros are enabled (File > Options > Trust Center > Trust Center Settings > Macro Settings) and that you are running the correct macro from the right workbook.

Frequently Asked Questions

How do I set percentage format for an entire column?

Use Columns("A").NumberFormat = "0.00%" or Range("A:A").NumberFormat = "0.00%".

What is the difference between NumberFormat and NumberFormatLocal?

NumberFormat uses the US English format codes (e.g., "0.00%") regardless of your system locale. NumberFormatLocal uses the format codes as they appear in your local Excel version, which may use different separators.

Can I apply percentage format to multiple non-contiguous ranges?

Yes. Use Union(Range("A1:A10"), Range("C1:C10")).NumberFormat = "0.00%".

Why does my cell show 2500% instead of 25%?

The cell contains 25, not 0.25. Percentage format multiplies the displayed value by 100, so 25 becomes 2500%. Either enter 0.25 or divide the value by 100 in your macro.

Does changing the number format change the cell value?

No. NumberFormat only changes how the value is displayed. The underlying value remains the same, and formulas use the underlying value.

How do I remove percentage formatting?

Set NumberFormat = "General" to return to the default display.