acos function

Philosophaie

Active Member
Joined
Mar 5, 2010
Messages
254
I am having trouble with my acos function:

d=Application.WorksheetFunction.acos(c)

where c is in radians and there is no error in it.

The error statement says:

"Unable to get the Acos property of the WorksheetFunction class"

I know there are other ways of getting the Acos function to work in VBA so could someone show me the way?
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Hi, This is one way:-
Code:
Dim oDeg, orad
oDeg = 30
orad = oDeg * Application.Pi / 180
MsgBox Cos(orad) 'cos of 30 dgrees= 0.866025404
MsgBox Application.Acos(0.866025404) * (180 / Application.Pi()) '= 30 Degrees
Regards Mck
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
7,940
Is the value of c between -1 and 1? If not, your ACOS function will return an error and you'll get the message you're seeing...
 

Forum statistics

Threads
1,081,690
Messages
5,360,614
Members
400,592
Latest member
badgergurl

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top