Results 1 to 4 of 4
  1. #1
    Cubalibre4u is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2021
    Posts
    1

    Translate Excel code ATAN2 in Query

    How can i translate a ATAN2 formule form EXCEL to ACCES?



    =ALS(F2>0;GRADEN(BOOGTAN2(E2;F2));360+GRADEN(BOOGT AN2(E2;F2)))

    Is it possible to translate it in a Access table calcultion field?

    Greetings Ed

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    First, calculated table fields should be avoided because calculations should not be stored as a general rule, rather they are calculated when needed. Second, calculated table fields have minimal options and they don't even come close for your request. I have used Excel functions in Access by setting a reference to Excel but I can't recall which one(s) that I was using. Just saying that may be an option. Where you have BOOGTAN2 - that is an untranslated word for ATAN2?

    You might need to post this in an Excel forum that also supports Access users if a reference to Excel from your Access vba code project doesn't help.
    Please follow cross posting etiquette guidelines (provide links to the other site(s) ) if you do.

    EDIT - There is a list of built in Access functions here (scroll down for math)
    https://support.microsoft.com/en-us/...2-658ce330ed83

    It's a far shorter list than Excel math functions.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    I have no idea what that Excel formula means
    However, I have a number of trig functions including this for getting the arctangent of 2 values.
    Its several years since I used it & please don't ask me to explain it!

    Code:
    Public Function Atn2(Y As Double, X As Double) As Double
    
    'Arctangent of 2 values (e.g. lat/long)
    
      If X > 0 Then
        Atn2 = Atn(Y / X)
      ElseIf X < 0 Then
        Atn2 = Sgn(Y) * (Pi - Atn(Abs(Y / X)))
      ElseIf Y = 0 Then
        Atn2 = 0
      Else
        Atn2 = Sgn(Y) * Pi / 2
      End If
    
    
    End Function
    For example:
    ?Atn2(54.1245,-2.162)
    1.61072004350471

    Compare what you get in Excel with that function in Access.
    Any use?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    And that works provided you have a reference to Excel (you didn't state that is was a requirement)?
    With such a reference, I tested a simple attempt to call an Excel built in function with

    Code:
    Dim result as Double
    
    result = Excel.Application.WorksheetFunction.Atan2(1, 2)
    MsgBox result
    I got a result over 1.1 but it means nothing to me.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 10-18-2020, 10:00 AM
  2. Replies: 1
    Last Post: 12-06-2019, 02:44 PM
  3. Anyone able to translate a formula from excel?
    By dniezby in forum Programming
    Replies: 10
    Last Post: 05-21-2013, 01:10 PM
  4. Please help translate below VB code
    By eric.kung in forum Programming
    Replies: 1
    Last Post: 08-25-2011, 07:28 AM
  5. Replies: 0
    Last Post: 09-03-2009, 01:58 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums