Consulting

Results 1 to 6 of 6

Thread: Complex numbers in VBA

  1. #1
    VBAX Regular
    Joined
    Jan 2005
    Posts
    6
    Location

    Complex numbers in VBA

    Hi
    Have somebody use the Complex Numbers Functions like IMPRODUCT or IMDIV in VBA function?
    Thanks in advance

  2. #2
    VBAX Regular
    Joined
    Jan 2005
    Posts
    6
    Location
    Sorry, something went wrong during posting the message.
    The actual question is related to correct extracting the complex number from the function and placing it into a cell ready for another operation with excel complex functions.

    Thanks
    Last edited by Valex; 12-05-2005 at 12:40 PM. Reason: wrong message

  3. #3
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    To use those functions in VBA you would need to set a reference to atpvbaen.xls in the VBA editor under Tools>References...

    I've never used these functions in Excel or VBA so I don't know what the synyax/code would be for what you want to do.

  4. #4
    VBAX Regular
    Joined
    Jan 2005
    Posts
    6
    Location
    Thanks Norie

    Having a cell name ww ="2+2j", the function is

    Function GatFsw(ww)
    GatFsw = WorksheetFunction.IMPRODUCT(ww, 2)
    End Function

    The function is called by GatFsw(ww) and terurns #VALUE!

    On the other side cell =IMPRODUCT(ww,2) is returning correct result 4+4j

  5. #5
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Valex

    Try removing WorksheetFunction.

  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,938
    Location
    If you have your reference set right (VBE | Tools | References) then you just call them on their own, they are not part of the WorksheetFunction object.

    Syntax is:
    IMPRODUCT(number1, number2, number3...number 29)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •