+ Reply to Thread
Results 1 to 4 of 4

"Reference is not Valid" when calling fast fourier transform

  1. #1
    JacksonRJones
    Guest

    "Reference is not Valid" when calling fast fourier transform

    Hello. I get the message "Reference is not Valid" when the following piece
    of code executes from my program; k is an integer, focallength is a double,
    and sheetname is a string:

    sheetname = "r32-" & k + 1 & "-" & FocalLength

    Dim infourierrng As Range
    Dim outfourierrng As Range

    Set infourierrng = Worksheets(sheetname).Range("J15:J1038")
    Set outfourierrng = Worksheets(sheetname).Range("L15:L1038")

    Application.Run "ATPVBAEN.XLA!Fourier", infourierrng, outfourierrng, False,
    False

    This message appears in a messagebox; if I click OK, everything proceeds
    fine, and the fourier transform works, so it isn't really much of a problem,
    except I don't want this message to appear anytime anyone runs this macro.
    Any help would be greatly appreciated.



  2. #2
    K Dales
    Guest

    RE: "Reference is not Valid" when calling fast fourier transform

    Seems like the issue occurs somewhere within the external procedure
    "ATPVBAEN.XLA!Fourier. Without knowing the code behind that procedure there
    is no way to know why the messagebox appears or how to prevent it.

    --
    - K Dales


    "JacksonRJones" wrote:

    > Hello. I get the message "Reference is not Valid" when the following piece
    > of code executes from my program; k is an integer, focallength is a double,
    > and sheetname is a string:
    >
    > sheetname = "r32-" & k + 1 & "-" & FocalLength
    >
    > Dim infourierrng As Range
    > Dim outfourierrng As Range
    >
    > Set infourierrng = Worksheets(sheetname).Range("J15:J1038")
    > Set outfourierrng = Worksheets(sheetname).Range("L15:L1038")
    >
    > Application.Run "ATPVBAEN.XLA!Fourier", infourierrng, outfourierrng, False,
    > False
    >
    > This message appears in a messagebox; if I click OK, everything proceeds
    > fine, and the fourier transform works, so it isn't really much of a problem,
    > except I don't want this message to appear anytime anyone runs this macro.
    > Any help would be greatly appreciated.
    >
    >


  3. #3
    JacksonRJones
    Guest

    RE: "Reference is not Valid" when calling fast fourier transform

    ATPVBAEN.XLA!Fourier is part of the standard analysis toolpack that comes
    with with excel 2003. It can be accessed from the tools->data analysis menu
    in excel. I think the problem has something to do with using the sheetname
    as a variable, because I did not get this error message when I was just using
    "sheet1" in place of the variable sheetname. Anyways, maybe this will help
    someone figure out what the problem is. Thanks.

    "K Dales" wrote:

    > Seems like the issue occurs somewhere within the external procedure
    > "ATPVBAEN.XLA!Fourier. Without knowing the code behind that procedure there
    > is no way to know why the messagebox appears or how to prevent it.
    >
    > --
    > - K Dales
    >
    >
    > "JacksonRJones" wrote:
    >
    > > Hello. I get the message "Reference is not Valid" when the following piece
    > > of code executes from my program; k is an integer, focallength is a double,
    > > and sheetname is a string:
    > >
    > > sheetname = "r32-" & k + 1 & "-" & FocalLength
    > >
    > > Dim infourierrng As Range
    > > Dim outfourierrng As Range
    > >
    > > Set infourierrng = Worksheets(sheetname).Range("J15:J1038")
    > > Set outfourierrng = Worksheets(sheetname).Range("L15:L1038")
    > >
    > > Application.Run "ATPVBAEN.XLA!Fourier", infourierrng, outfourierrng, False,
    > > False
    > >
    > > This message appears in a messagebox; if I click OK, everything proceeds
    > > fine, and the fourier transform works, so it isn't really much of a problem,
    > > except I don't want this message to appear anytime anyone runs this macro.
    > > Any help would be greatly appreciated.
    > >
    > >


  4. #4
    JacksonRJones
    Guest

    RE: "Reference is not Valid" when calling fast fourier transform

    In case anyone reads this, I ended up fixing this problem by activating the
    worksheet which had the data I wanted to do the fft on and then defining the
    range for the active worksheet, then referring this range for the fft:

    Worksheets(sheetname).Activate

    Set infourierrng = Range("J15:J1038")
    Set outfourierrng = Range("L15:L1038")

    Application.Run "ATPVBAEN.XLA!Fourier", infourierrng, outfourierrng, False,
    False


    "JacksonRJones" wrote:

    > Hello. I get the message "Reference is not Valid" when the following piece
    > of code executes from my program; k is an integer, focallength is a double,
    > and sheetname is a string:
    >
    > sheetname = "r32-" & k + 1 & "-" & FocalLength
    >
    > Dim infourierrng As Range
    > Dim outfourierrng As Range
    >
    > Set infourierrng = Worksheets(sheetname).Range("J15:J1038")
    > Set outfourierrng = Worksheets(sheetname).Range("L15:L1038")
    >
    > Application.Run "ATPVBAEN.XLA!Fourier", infourierrng, outfourierrng, False,
    > False
    >
    > This message appears in a messagebox; if I click OK, everything proceeds
    > fine, and the fourier transform works, so it isn't really much of a problem,
    > except I don't want this message to appear anytime anyone runs this macro.
    > Any help would be greatly appreciated.
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1