VBA & Macro Problems

Create an Excel VBA Function to Convert Degrees, Minutes, and Seconds

Adam DavisAdam Davis Dec 2, 2026 869 views

Question details

Create a VBA function that converts degrees, minutes, and seconds in the three cells to the left into decimal degrees.

Create an Excel VBA Function to Convert Degrees, Minutes, and Seconds
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA editor

In desktop Excel, open the workbook, press Alt+F11, and select Insert > Module.

2
Add the function

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

3
Enter the worksheet formula

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.

4
Save as a macro-enabled workbook

Choose File > Save As and select Excel Macro-Enabled Workbook (*.xlsm). Enable macros when prompted only if you trust the workbook.

Create a VBA function that reads the three cells to its left
Recalculate after changing inputs: Because the function reads cells through Application.Caller rather than formula arguments, Excel may not detect those cells as dependencies. Press F9 to recalculate if a result does not update.
Convert angles in WPS Spreadsheets

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. 1. Open a spreadsheet: Open WPS Office, choose Spreadsheets, and open your workbook or create a new sheet.
  2. 2. Arrange the angle values: Enter degrees in A1, minutes in B1, and seconds in C1.
  3. 3. Calculate decimal degrees: Select D1, enter =A1+B1/60+C1/3600, and press Enter.
  4. 4. Calculate additional rows: Select D1 and drag its fill handle down alongside the remaining values.
Convert adjacent degree, minute, and second values with a simple formulaOpen and edit Microsoft Excel XLSX filesUse a familiar spreadsheet interface without writing VBAFill the formula down for multiple rows
microsoft office alternative - wps office

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.