• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / VBA / VBA Convert Radians to Degrees with WorksheetFunction.Degrees()

VBA Convert Radians to Degrees with WorksheetFunction.Degrees()

February 5, 2022 Leave a Comment

To convert radians to degrees for use in trigonometric functions in VBA, the easiest way is with the Excel worksheet function Degrees().

degrees = WorksheetFunction.Degrees(WorksheetFunction.Pi/2)

The VBA collection of math functions has many powerful functions which make performing certain calculations in VBA very easy.

Unfortunately, VBA doesn’t have a function which converts radians to degrees, but we can use the Excel worksheet function Degrees() to convert radians to degrees easily.

We can convert radians to degrees easily with the Excel worksheet function Degrees().

To do so, we need to pass any number to the Degrees() worksheet function.

Below are a few examples of how to use the Degrees() worksheet function to convert different angles, in radians, to degrees with in VBA.

Debug.Print WorksheetFunction.Degrees(0)
Debug.Print WorksheetFunction.Degrees(WorksheetFunction.Pi/6)
Debug.Print WorksheetFunction.Degrees(WorksheetFunction.Pi/3)
Debug.Print WorksheetFunction.Degrees(WorksheetFunction.Pi/2)

'Output:
0
30
60
90

If you’d like to go the other way, converting degrees to radians, you can use the Radians() Excel worksheet function.

Converting Radians to Degrees Without the Degrees() Worksheet function in VBA

Converting radians to degrees is a very easy formula. To convert radians to degrees, all we need to do is multiply the degrees by 180 and divide by pi.

We can convert radians to degrees without the help of the math module easily in VBA.

Below is a user-defined function which will convert radians to degrees for us in our VBA code.

Function radians_to_degrees(radians as Double) as Double 
  radians_to_degrees = radians * (180 / WorksheetFunction.Pi)
End Function

Let’s test the function to verify that we get the same results as the Degrees() function.

Function radians_to_degrees(radians as Double) as Double 
  radians_to_degrees = radians * (180 / WorksheetFunction.Pi)
End Function

Debug.Print radians_to_degrees(0);
Debug.Print radians_to_degrees(WorksheetFunction.Pi/6);
Debug.Print radians_to_degrees(WorksheetFunction.Pi/3);
Debug.Print radians_to_degrees(WorksheetFunction.Pi/2);

'Output:
0
30
60
90

As you can compare for yourself to the example above, we get the same results as using Degrees().

Hopefully this post was helpful for you to learn how to convert radians to degrees in VBA with and without the Degrees() Excel worksheet function.

Other Articles You'll Also Like:

  • 1.  VBA Cosh Worksheet Function – Find Hyperbolic Cosine of Number
  • 2.  How to Get Column Letter from Number Using an Excel VBA Macro
  • 3.  VBA Tan – Find Tangent of Number in Radians Using VBA Tan() Function
  • 4.  VBA Acos Worksheet Function – Find Arccosine of Number
  • 5.  VBA Cos – Find Cosine of Number in Radians Using VBA Cos() Function
  • 6.  VBA Atn – Find Arctangent and Inverse Tangent of Number
  • 7.  VBA pi – Get Value of pi Using Excel pi Worksheet Function
  • 8.  VBA Sin – Find Sine of Number in Radians Using VBA Sin() Function
  • 9.  VBA Trig – Using Trigonometric Functions in VBA for Trigonometry
  • 10.  VBA Tanh Worksheet Function – Find Hyperbolic Tangent of Number

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy