Create an Excel VBA Function to Convert Degrees, Minutes, and Seconds
Question details
Create a VBA function that converts degrees, minutes, and seconds in the three cells to the left into decimal degrees.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet has degrees, minutes, and seconds in adjacent cells, followed by a cell for the decimal-degree result.
- Observed behavior
- The user wants a function that reads the three preceding cells and returns their combined value in decimal degrees.
Arrange numeric degrees, minutes, and seconds in three consecutive columns, such as A, B, and C, with the result in column D. The calculation below adds the three signed values; if a negative sign applies to the entire angle, handle that sign separately.
Create a VBA function that reads the three cells to its left
Use this function when you want to enter a short formula beside each set of degree, minute, and second values.
In desktop Excel, open the workbook, press Alt+F11, and select Insert > Module.
Paste this code into the module: Function DMSDecimal() As Double DMSDecimal = Application.Caller.Offset(0, -3).Value + Application.Caller.Offset(0, -2).Value / 60 + Application.Caller.Offset(0, -1).Value / 3600 End Function
Return to the worksheet and enter =DMSDecimal() in D1 when degrees, minutes, and seconds are in A1, B1, and C1. Fill the formula down for additional rows.
Choose File > Save As and select Excel Macro-Enabled Workbook (*.xlsm). Enable macros when prompted only if you trust the workbook.

Convert the values with an Excel worksheet formula
Use a formula instead of VBA when you do not need a custom function.
Convert degrees, minutes, and seconds in WPS Spreadsheets
Use a worksheet formula in WPS Spreadsheets to calculate decimal degrees without creating a VBA function.
- 1. Open a spreadsheet: Open WPS Office, choose Spreadsheets, and open your workbook or create a new sheet.
- 2. Arrange the angle values: Enter degrees in A1, minutes in B1, and seconds in C1.
- 3. Calculate decimal degrees: Select D1, enter =A1+B1/60+C1/3600, and press Enter.
- 4. Calculate additional rows: Select D1 and drag its fill handle down alongside the remaining values.

Frequently Asked Questions
Where should I enter the DMSDecimal function?
Enter =DMSDecimal() in the cell immediately to the right of the seconds value. For inputs in A1:C1, enter it in D1.
How do I convert a negative angle?
If the negative sign applies to the whole angle and the minutes and seconds are positive, negate the combined magnitude. For example, use =-(ABS(A1)+B1/60+C1/3600) for an angle known to be negative.
Why doesn't my VBA result update when I change an input?
Excel may not recognize cells read through Application.Caller as formula dependencies. Press F9 to recalculate, or use =A1+B1/60+C1/3600 so the references are explicit.
Do I need to save the workbook in a special format?
Yes. To retain the VBA function, choose File > Save As and save the workbook as an Excel Macro-Enabled Workbook (*.xlsm). A worksheet formula alone does not require this format.




