Sub
LoopAllExcelFilesInFolder()
Dim
wb
As
Workbook
Dim
myPath
As
String
Dim
myFile
As
String
Dim
myExtension
As
String
Dim
FldrPicker
As
FileDialog
Application.ScreenUpdating =
False
Application.EnableEvents =
False
Application.Calculation = xlCalculationManual
Set
FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With
FldrPicker
.Title =
"Select A Target Folder"
.AllowMultiSelect =
False
If
.Show <> -1
Then
GoTo
NextCode
myPath = .SelectedItems(1) & "\"
End
With
NextCode:
myPath = myPath
If
myPath =
""
Then
GoTo
ResetSettings
myExtension =
"*.csv"
myFile = Dir(myPath & myExtension)
Do
While
myFile <>
""
Set
wb = Workbooks.Open(Filename:=myPath & myFile)
Dim
i
As
Integer
Dim
j
i = 0
j = 0
Columns(
"A:A"
).
Select
Application.CutCopyMode =
False
Selection.TextToColumns Destination:=Range(
"A1"
), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=
False
, Tab:=
True
, _
Semicolon:=
True
, Comma:=
False
, Space:=
False
, Other:=
False
, FieldInfo _
:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=
True
For
i = 19
To
522
If
Cells(i, 4).Value >= Cells(i, 5).Value
And
Cells(i, 4).Value <= Cells(i, 6).Value
Or
Cells(i, 4).Value =
"0"
Or
Cells(i, 7).Value =
"-"
Or
Cells(i, 7).Value =
"mm"
Or
Cells(i, 4).Value =
"Value"
Or
Cells(i, 7).Value =
"mbar"
Or
Cells(i, 7).Value =
"Grad"
Or
Cells(i, 7).Value =
"ccm/min"
Or
Cells(i, 6).Value =
""
Or
Cells(i, 5).Value =
""
Or
Cells(i, 2).Value =
"OP1200OS"
Or
Cells(i, 2).Value =
"OP1200CS"
Then
Rows(i).Delete
Else
Range(Cells(i, 1), Cells(i, 8)).Interior.Color = RGB(255, 0, 0)
i = i + 1
End
If
i = i - 1
j = Cells(i, 1).Value
If
j =
"time"
Then
Exit
Sub
If
j = 0
Then
Exit
Sub
Next
i
myFile = Dir
Loop
MsgBox
"Task Complete!"
ResetSettings:
Application.EnableEvents =
True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating =
True
End
Sub