• 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 Degrees to Radians with WorksheetFunction.Radians()

VBA Convert Degrees to Radians with WorksheetFunction.Radians()

February 5, 2022 Leave a Comment

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

radians = WorksheetFunction.Radians(60)

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 degrees to radians, but we can use the Excel worksheet function Radians() to convert degrees to radians easily.

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

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

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

Debug.Print WorksheetFunction.Radians(0)
Debug.Print WorksheetFunction.Radians(30)
Debug.Print WorksheetFunction.Radians(60)
Debug.Print WorksheetFunction.Radians(90)

'Output:
0
0.523598775598299
1.0471975511966
1.5707963267949

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

Converting Degrees to Radians Without Radians() Worksheet Function in VBA

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

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

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

Function degrees_to_radians(degrees As Double) As Double
  degrees_to_radians = degrees * (WorksheetFunction.Pi / 180)
End Function

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

Function degrees_to_radians(degrees As Double) As Double
  degrees_to_radians = degrees * (WorksheetFunction.Pi / 180)
End Function

Debug.Print degrees_to_radians(0);
Debug.Print degrees_to_radians(30);
Debug.Print degrees_to_radians(60);
Debug.Print degrees_to_radians(90);

'Output:
0
0.523598775598299
1.0471975511966
1.5707963267949

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

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

Other Articles You'll Also Like:

  • 1.  VBA Cosh Worksheet Function – Find Hyperbolic Cosine of Number
  • 2.  VBA Sin – Find Sine of Number in Radians Using VBA Sin() Function
  • 3.  VBA Atn – Find Arctangent and Inverse Tangent of Number
  • 4.  VBA e – Using Exp() Function to Get Euler’s Constant e
  • 5.  How to Get Column Letter from Number Using an Excel VBA Macro
  • 6.  VBA Asinh Worksheet Function – Find Inverse Hyperbolic Arcsine of Number
  • 7.  VBA Tan – Find Tangent of Number in Radians Using VBA Tan() Function
  • 8.  VBA Atanh Worksheet Function – Inverse Hyperbolic Arctangent of Number
  • 9.  VBA Trig – Using Trigonometric Functions in VBA for Trigonometry
  • 10.  VBA Cos – Find Cosine of Number in Radians Using VBA Cos() Function

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

x