Forum Discussion
How do I permanently save a custom number format in Excel?
If you want to apply a custom number format without using VBA, you can still achieve it using Excel's built-in functionality.
Here's how you can do it:
- Select the cells to which you want to apply the custom number format.
 - Right-click on the selected cells and choose "Format Cells" from the context menu.
 - In the Format Cells dialog box, go to the "Number" tab.
 - Select the "Custom" category.
 - In the "Type" field, enter your desired custom number format. For example, you can enter "dd° mm' ss''" for degrees, minutes, and seconds.
 - Click "OK" to apply the custom number format to the selected cells.
 
The selected cells will now be formatted with your custom number format.
This method doesn't require VBA and allows you to apply the custom number format directly using Excel's user interface. The formatting will be applied to the selected cells and will persist until you change it. You can use this method in any workbook without the need for VBA code.
OR…you can use VBA to apply a custom number format to cells in Excel.
Here's an example of how you can do it:
Sub ApplyCustomNumberFormat()
    Dim customFormat As String
    customFormat = "dd° mm' ss''" ' Replace with your desired custom number format
    
    ' Apply custom number format to selected cells
    Selection.NumberFormat = customFormat
End SubHere's how to use this VBA code:
- Press Alt+F11 to open the VBA editor.
 - Insert a new module by clicking "Insert" > "Module."
 - Copy and paste the above VBA code into the module.
 - Replace "dd° mm' ss''" with your desired custom number format inside the customFormat variable.
 - Close the VBA editor.
 - Select the cells to which you want to apply the custom number format.
 - Press Alt+F8 to open the "Macro" dialog box.
 - Select the "ApplyCustomNumberFormat" macro and click "Run."
 
The selected cells will now be formatted with your custom number format.
You can assign the macro to a button or a keyboard shortcut for easier access. To do this, right-click on the button or go to "File" > "Options" > "Customize Ribbon" to assign a keyboard shortcut.