BEADG
10-25-2018, 01:45 AM
Hi guys,
Recently I had to calculate some data with Fast Fourier Transformation (FFT).
At the beginning I used data analysis toolpak in the worksheet directly which worked.
since I have to do it quite often in thenext time I tried to do it in VBA.
The Macro works just fine basically.
I always get a set of 30 test runs which I analyze.The macro I have works and is also fast enough.
But I know it is just super complicatedwhat I did for no reason :D
Can you help me to find a more clever wayto write the macro and also to make it flexible in case I have 28 or 32datasets and not exactly 30?
What I have is that (I cut it after 5thrun as it is super long otherwise):
Sub CalcFFT512()
'
' CalcFFT with 512 samples
On Error GoTo ExitNow
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
'1
Application.Run "ATPVBAEN.XLAM!Fourier", ActiveSheet.Range("$D$8:$D$519") _
, ActiveSheet.Range("$AI$8"), False, False
'2
Application.Run "ATPVBAEN.XLAM!Fourier", ActiveSheet.Range("$E$8:$E$519") _
, ActiveSheet.Range("$AL$8"), False, False
'3
Application.Run "ATPVBAEN.XLAM!Fourier", ActiveSheet.Range("$F$8:$F$519") _
, ActiveSheet.Range("$AO$8"), False, False
'4
Application.Run "ATPVBAEN.XLAM!Fourier", ActiveSheet.Range("$G$8:$G$519") _
, ActiveSheet.Range("$AO$8"), False, False
'5 and so on....
ExitNow:
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Any good idea?
Best regards
Steffen
Recently I had to calculate some data with Fast Fourier Transformation (FFT).
At the beginning I used data analysis toolpak in the worksheet directly which worked.
since I have to do it quite often in thenext time I tried to do it in VBA.
The Macro works just fine basically.
I always get a set of 30 test runs which I analyze.The macro I have works and is also fast enough.
But I know it is just super complicatedwhat I did for no reason :D
Can you help me to find a more clever wayto write the macro and also to make it flexible in case I have 28 or 32datasets and not exactly 30?
What I have is that (I cut it after 5thrun as it is super long otherwise):
Sub CalcFFT512()
'
' CalcFFT with 512 samples
On Error GoTo ExitNow
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
'1
Application.Run "ATPVBAEN.XLAM!Fourier", ActiveSheet.Range("$D$8:$D$519") _
, ActiveSheet.Range("$AI$8"), False, False
'2
Application.Run "ATPVBAEN.XLAM!Fourier", ActiveSheet.Range("$E$8:$E$519") _
, ActiveSheet.Range("$AL$8"), False, False
'3
Application.Run "ATPVBAEN.XLAM!Fourier", ActiveSheet.Range("$F$8:$F$519") _
, ActiveSheet.Range("$AO$8"), False, False
'4
Application.Run "ATPVBAEN.XLAM!Fourier", ActiveSheet.Range("$G$8:$G$519") _
, ActiveSheet.Range("$AO$8"), False, False
'5 and so on....
ExitNow:
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Any good idea?
Best regards
Steffen