'############################################################################################################################################
Dim objFSO As Object 'Scripting.FileSystemObject
Dim fldr As Object 'Scripting.Folder
Dim f As Object 'Scripting.File
Set objFSO = CreateObject("Scripting.FileSystemObject")
With objFSO
Set fldr = .GetFolder(p)
If fldr.Files.Count > 0 Then
NumberofRuns = fldr.Files.Count
For Each f In fldr.Files
i = i + 1 '//pretend we are in a [for i = 1 to x loop], instead of a [for each loop]
Filename = f.Path '//use f.Path to get full path to file (C:\folder\file.txt), use f.Name to get just name of file (file.txt)
'############################################################################################################################
Sheets("GM Template").Copy After:=Sheets(i + 2 + k)
Sheets("GM Template (2)").Name = "GM Table " & i
Sheets("S&H Template").Copy After:=Sheets(i + 3 + k)
Sheets("S&H Template (2)").Name = "S&H Run " & i
Workbooks.OpenText Filename:=Filename _
, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _
:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:= _
False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1)
MyReport = ActiveWorkbook.Name
Range("A1").Select
Selection.End(xlDown).Select
RowEnd = ActiveCell.Row
Range("A1").Select
Selection.End(xlToRight).Select
ColumnEnd = ActiveCell.Column
Range(Cells(1, 1), Cells(RowEnd, ColumnEnd)).Select
Cells.Select
Selection.Sort Key1:=Range(SearchColumn), Order1:=xlAscending, Key2:=Range("A2") _
, Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False _
, Orientation:=xlTopToBottom
Range(Cells(1, 1), Cells(RowEnd, ColumnEnd)).Copy
Windows(MyBook).Activate
Sheets("GM Table " & i).Select
Range("A1").Select
ActiveSheet.Paste
Windows(MyReport).Activate
Application.DisplayAlerts = False
ActiveWorkbook.Close
If DyeSet = "DS33" Then
Call DS33
ElseIf DyeSet = "DS30" Then
Call DS30
ElseIf DyeSet = "Identifiler" Then
Call Identifiler
ElseIf DyeSet = "ProPlus" Then
Call ProPlus
ElseIf DyeSet = "SNaPshot" Then
Call SNaPshot
ElseIf DyeSet = "ALFP" Then
Call ALFP
End If
k = k + 1
Sheets("S&H Summary").Select
Range("B4").Select
If ActiveCell.Value <> False Then
Selection.End(xlToRight).Select
ColumnTracker = ActiveCell.Column
PasteColumn = ColumnTracker + 1
Else
PasteColumn = 2
End If
Sheets("S&H Run " & i).Select
Range("B2:C34").Copy
Sheets("S&H Summary").Select
Cells(4, PasteColumn).Select
Selection.PasteSpecial Paste:=xlValues
Selection.NumberFormat = "0.00"
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Cells(3, PasteColumn).Value = "Run " & i
If CapFlag <> 0 Then
Cells(2, PasteColumn).Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Cells(2, PasteColumn).Value = CapFlag
ElseIf MissingFlag <> 0 Then
Cells(1, PasteColumn).Select
With Selection.Interior
.ColorIndex = 46
.Pattern = xlSolid
End With
Cells(1, PasteColumn).Value = MissingFlag
End If
For j = 5 To 5 + UBound(Alleles)
Cells(j, PasteColumn + 1).Select
If IsNumeric(ActiveCell.Value) = False Then
Range(Cells(j, PasteColumn), Cells(j, PasteColumn + 1)).Select
Selection.ClearContents
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
ElseIf ActiveCell.Value >= Precision Then
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
Next j
Sheets("S&H Run " & i).Select
Range("D2:E34").Copy
Sheets("S&H Summary").Select
Cells(39, PasteColumn).Select
Selection.PasteSpecial Paste:=xlValues
Selection.NumberFormat = "0.0"
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Cells(38, PasteColumn).Value = "Run " & i
For j = 40 To 40 + UBound(Alleles)
Cells(j, PasteColumn).Select
If IsNumeric(ActiveCell.Value) = False Then
Range(Cells(j, PasteColumn), Cells(j, PasteColumn + 1)).Select
Selection.ClearContents
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
ElseIf ActiveCell.Value <= 150 And ActiveCell.Value <> "" And DyeSet <> "ALFP" Then
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
Next j
Cells(73, PasteColumn).Value = MyReport
Next i
Else
MsgBox ("Empty Folder")
Exit Sub
End If
End With
If DyeSet = "DS33" Then
Call DS33Summary
ElseIf DyeSet = "DS30" Then
Call DS30Summary
ElseIf DyeSet = "Identifiler" Then
Call IdentifilerSummary
ElseIf DyeSet = "ProPlus" Then
Call ProPlusSummary
ElseIf DyeSet = "SNaPshot" Then
Call SNaPshotSummary
ElseIf DyeSet = "ALFP" Then
Call ALFPSummary
End If
End Sub