+ Reply to Thread
Results 1 to 6 of 6

Fourier analysis with variable input

Hybrid View

  1. #1
    Registered User
    Join Date
    12-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Fourier analysis with variable input

    I have two pieces of code. The first one runs fine, the second one gives the run-time error '1004' Application-defined or object-define error. Could someone help me? As you can see, I am trying to sweep through columns and calculate Fourier transforms.

    1st (runs well)
    Application.Run "ATPVBAEN.XLAM!Fourier", Worksheets("Red").Range("$A1:A128"), _
    Worksheets("Analysis - Red").Range("AV430"), False, False

    2nd (run-time error)
    i = 1

    Application.Run "ATPVBAEN.XLAM!Fourier", Worksheets("Red").Range(Cells(1, i), Cells(128, i)), _
    Worksheets("Analysis - Red").Range(Cells(430, 48 + i)), False, False

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,947

    Re: Fourier analysis with variable input

    No sample workbook provided so try (can't test):
    Application.Run "ATPVBAEN.XLAM!Fourier", Worksheets("Red").Range(Cells(1, i).Address).Resize(rowsize:=128), _
     Worksheets("Analysis - Red").Range(Cells(430, 48 + i).Address), False, False
    Notice that "$A1:A128" and "AV430" in the first are string references which are required by RANGE(). Cells(r,c).Address returns the string that Range is expecting.
    Last edited by protonLeah; 12-15-2013 at 09:55 PM.
    Ben Van Johnson

  3. #3
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: Fourier analysis with variable input

    Hi freirema and welcome to the forum,

    As per forum rules, please use code tags around your code.

    to answer your questions, make sure you reference the sheet correctly when you use the Cells(x,y) otherwise you may refer to the incorrect sheet (activesheet will be used)
    Also when defining a range, you need to specify 2 cells.
    For example :

    Application.Run "ATPVBAEN.XLAM!Fourier", Worksheets("Red").Range(Worksheets("Red").Cells(1, i), Worksheets("Red").Cells(128, i)), _
    Worksheets("Analysis - Red").Range(Worksheets("Analysis - Red").Cells(430, 48 + i),Worksheets("Analysis - Red").Cells(430, 48 + i) ), False, False
    or

    Application.Run "ATPVBAEN.XLAM!Fourier", Worksheets("Red").Range(Worksheets("Red").Cells(1, i), Worksheets("Red").Cells(128, i)), _
    Worksheets("Analysis - Red").Cells(430, 48 + i) , False, False
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,947

    Re: Fourier analysis with variable input

    deleted accidental repost
    Last edited by protonLeah; 12-15-2013 at 09:55 PM.

  5. #5
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: Fourier analysis with variable input

    @protonLeah,

    You are correct... my bad.

  6. #6
    Registered User
    Join Date
    12-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Fourier analysis with variable input

    I thank you both and apologize for not posting the code in the correct fashion (using tags).

    I have just tried the first suggestion and it worked! I am afraid I do not fully understand VBA so I am not sure why it worked but I am very happy.

    I also looked at the second suggestion but have not tried it yet. However, looking up the error message earlier today I understood it was about not having the proper reference to the sheet so I am pretty sure it will work as well.

    Thanks a lot again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Fourier Analysis
    By jordon in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  2. [SOLVED] Fourier Analysis
    By Gary's Student in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 09-06-2005, 05:05 PM
  3. Fourier Analysis
    By jordon in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  4. Fourier Analysis
    By jordon in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-18-2005, 07:05 PM
  5. [SOLVED] Fourier Analysis
    By Bruce in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-13-2005, 04:06 AM

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