I'm in need of a bit of help.
I am trying to run a Butterworth filter on a large number of separate files, then copy and paste into a different workbook select calculated values after filtering (Max, time to max, ...). I used this macro successfully once, but now need to apply a rolling average after the filtering. So I now have the raw values, run a butterworth filter vba, two columns of data that are calculated off of the filtered data, then a couple values that are calculated off of the previously mentioned two columns of data. The first time that worked was without the rolling average calculation (straight off filtered data). Now trying to get the values from the calculated rolling averages, it only pastes N/As and 0's. So it seems as though it is not calculating. If I do the same process manually it works fine. I have checked all of the normal solutions of various workbook calculations (manual v automatic) and changing the cell format to number.
Thanks in advance for the help.
Can send someone the excel file, just can't figure out how to post here.
Macro Below
I am trying to run a Butterworth filter on a large number of separate files, then copy and paste into a different workbook select calculated values after filtering (Max, time to max, ...). I used this macro successfully once, but now need to apply a rolling average after the filtering. So I now have the raw values, run a butterworth filter vba, two columns of data that are calculated off of the filtered data, then a couple values that are calculated off of the previously mentioned two columns of data. The first time that worked was without the rolling average calculation (straight off filtered data). Now trying to get the values from the calculated rolling averages, it only pastes N/As and 0's. So it seems as though it is not calculating. If I do the same process manually it works fine. I have checked all of the normal solutions of various workbook calculations (manual v automatic) and changing the cell format to number.
Thanks in advance for the help.
Can send someone the excel file, just can't figure out how to post here.
Macro Below
Sub File_Loop_Example()
'Excel VBA code to loop through files in a folder with Excel VBA
Dim MyFolder As String
Dim MyFile As String
'Opens a file dialog box for user to select a folder
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
MyFolder = .SelectedItems(1)
Err.Clear
End With
'stops screen updating, calculations, events, and statsu bar updates to help code run faster
'you'll be opening and closing many files so this will prevent your screen from displaying that
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
'This section will loop through and open each file in the folder you selected
'and then close that file before opening the next file
MyFile = Dir(MyFolder & "", vbReadOnly)
Do While MyFile <> ""
DoEvents
On Error GoTo 0
Workbooks.Open FileName:=MyFolder & "" & MyFile, UpdateLinks:=False
''''''''''''ENTER YOUR CODE HERE TO DO SOMETHING'''''''''
Workbooks("Macros.xlsm").Activate
Rows("1:2").Select
Application.CutCopyMode = False
Selection.Copy
Workbooks(MyFile).Activate
Rows("1:1").Select
Selection.Insert Shift:=xlDown
ActiveSheet.Paste
Application.Run "butfilter"
Application.CutCopyMode = False
Calculate
Range("F2:K2").Select
Selection.Copy
Workbooks("Kinetic Variables.xlsx").Activate
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(MyFile).Close SaveChanges:=False
MyFile = Dir
Loop
'turns settings back on that you turned off before looping folders
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
Application.Calculation = xlCalculationManual
End Sub
'Excel VBA code to loop through files in a folder with Excel VBA
Dim MyFolder As String
Dim MyFile As String
'Opens a file dialog box for user to select a folder
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
MyFolder = .SelectedItems(1)
Err.Clear
End With
'stops screen updating, calculations, events, and statsu bar updates to help code run faster
'you'll be opening and closing many files so this will prevent your screen from displaying that
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
'This section will loop through and open each file in the folder you selected
'and then close that file before opening the next file
MyFile = Dir(MyFolder & "", vbReadOnly)
Do While MyFile <> ""
DoEvents
On Error GoTo 0
Workbooks.Open FileName:=MyFolder & "" & MyFile, UpdateLinks:=False
''''''''''''ENTER YOUR CODE HERE TO DO SOMETHING'''''''''
Workbooks("Macros.xlsm").Activate
Rows("1:2").Select
Application.CutCopyMode = False
Selection.Copy
Workbooks(MyFile).Activate
Rows("1:1").Select
Selection.Insert Shift:=xlDown
ActiveSheet.Paste
Application.Run "butfilter"
Application.CutCopyMode = False
Calculate
Range("F2:K2").Select
Selection.Copy
Workbooks("Kinetic Variables.xlsx").Activate
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks(MyFile).Close SaveChanges:=False
MyFile = Dir
Loop
'turns settings back on that you turned off before looping folders
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
Application.Calculation = xlCalculationManual
End Sub