none
Fourier analysis and screen update RRS feed

  • Question

  • Is it possible to run a Fourier transform in VBA without screen update? For instance if the example code below is run whilst displaying sheet 1, one would expect the analysis results to be written in sheet 2 whilst still displaying sheet 1. However, the screen is updated to show sheet 2? Can anybody suggest a method to run a Fourier transform without the screen being updated?

    Sub Macro()
       
        Application.ScreenUpdating = False
       
        Application.Run "Fourier", Sheets("sheet1").Range("$A$1:$A$16"), _
            Sheets("sheet2").Range("$I$1"), False, False

    End Sub

    • Moved by Youen Zen Wednesday, February 1, 2012 3:02 AM (From:Visual Basic General)
    Monday, January 30, 2012 12:56 PM

Answers

  • I think your problem is not that the screen flickers, but that you just want to get back to Sheet1 after running the Fourier transform. If that is the case, just include some code to select the original data. Like this,

    Sub Macro()
        
    Application.ScreenUpdating = False
    
    Application.Run "Fourier", Sheets("sheet1").Range("$A$1:$A$16"), _
        Sheets("sheet2").Range("$I$1"), False, False
    
    Sheets("Sheet1").Activate
    Range("$A$1").Select
    
    End Sub


    Ed Ferrero
    www.edferrero.com

    Wednesday, February 15, 2012 1:06 AM

All replies

  • Try the forum for Visual Basic for Applications.

    http://social.msdn.microsoft.com/Forums/en-US/isvvba

    This one is for Visual Basic with Visual Studio Net

     


    Success
    Cor
    Monday, January 30, 2012 2:09 PM
  • Is it possible to run a Fourier transform in VBA without screen update? For instance if the example code below is run whilst displaying sheet 1, one would expect the analysis results to be written in sheet 2 whilst still displaying sheet 1. However, the screen is updated to show sheet 2? Can anybody suggest a method to run a Fourier transform without the screen being updated?

    Sub Macro()
       
        Application.ScreenUpdating = False
       
        Application.Run "Fourier", Sheets("sheet1").Range("$A$1:$A$16"), _
            Sheets("sheet2").Range("$I$1"), False, False

    End Sub

     

    Monday, January 30, 2012 2:28 PM
  • What code do you have in your sub "Fourier"?
    HTH, Bernie
    Monday, January 30, 2012 6:29 PM
  • Dear Bernie

    There is no code in sub "Fourier". The Application.Run "Fourier" command runs the Fourier analysis which is part of the Data Analysis Toolpack. If you put any values is sheet1 range A1:A16 the above routine will calculate the Fourier transform and write the results in sheet 2. My question is why it actually displays the results in sheet 2, since the screenupdating = false command should prevent it from doing so? Any suggestions?

    Tuesday, January 31, 2012 6:23 AM
  • Everything is fine. ScreenUpdating prevents monitor updates when the macro is running. It doesn't "disable" screen permanently, when the macro is finished worksheet is updated.

    By the way, you should have set Application.ScreenUpdating = true at the end of the macro yourself. Have a look at remarks.

    Tuesday, January 31, 2012 7:34 AM
  • Dear Abcadlo

    Thanks for your reply.

    The sample code above is just to illustrate that, as far as I can see, one cannot prevent the screen from updating when running a Fourier transform. My problem is that I have a macro that runs the Fourier transform 200 times for 200 different arrays and the screen continuously flickers and updates when it calculates each transform. This is rather distracting and I was wondering how one can prevent the screen from updating? Any suggestions?

    Tuesday, January 31, 2012 11:23 AM
  • Hi  Gerhard,

    Welcome to MSDN forums.

    This is a VBA issue, in order to give you a better support , I will move it from “Visual Basic General” forum to “ Visual Basic for Applications (VBA)” forum.

    Thank you for your understanding!

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us
    Wednesday, February 1, 2012 3:02 AM
  • Hi Gerhard,

    How about the problem on your side?

    Do you still need any assistant about the problem?

    If you still show any concern on the problem, just feel free to let us know.
     
    Best Regards,


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"

    Tuesday, February 14, 2012 11:45 PM
    Moderator
  • I think your problem is not that the screen flickers, but that you just want to get back to Sheet1 after running the Fourier transform. If that is the case, just include some code to select the original data. Like this,

    Sub Macro()
        
    Application.ScreenUpdating = False
    
    Application.Run "Fourier", Sheets("sheet1").Range("$A$1:$A$16"), _
        Sheets("sheet2").Range("$I$1"), False, False
    
    Sheets("Sheet1").Activate
    Range("$A$1").Select
    
    End Sub


    Ed Ferrero
    www.edferrero.com

    Wednesday, February 15, 2012 1:06 AM