1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Option Explicit
Sub Resistivity()
Dim WB As Workbook, TreatedFile As Workbook
Dim Counter As Variant 'Declaration de counter
Dim a As Integer
Dim nom As String, ave As String, deviation As String, unit As String
Dim maximum As String, minimum As String
Dim dl As String, dc As String
Set WB = ThisWorkbook 'creation d'un nouveau fichier
Application.ScreenUpdating = False
Counter = Application.GetOpenFilename(",*.map", , , , True) 'Ouverture de la boite de dialogue pour selection des fichiers .txt
If VarType(Counter) = vbBoolean Then Exit Sub
For a = 1 To UBound(Counter)
Set TreatedFile = Application.Workbooks.Open(Counter(a), xlMSDOS)
With TreatedFile
With .Activesheet
dl = .Range("A65536").End(xlUp).Row
dc = .Range("IV1").End(xlToLeft).Column
.Range(.Cells(4, 1), .Cells(CInt(dl), CInt(dc))).Replace What:="0", Replacement:=" " , LookAt:=xlWhole
nom = .Name
maximum = Application.WorksheetFunction.max(.Range(.Cells(4, 1), .Cells(CInt(dl), CInt(dc))))
minimum = Application.WorksheetFunction.Min(.Range(.Cells(4, 1), .Cells(CInt(dl), CInt(dc))))
ave = Application.WorksheetFunction.average(.Range(.Cells(4, 1), .Cells(CInt(dl), CInt(dc))))
deviation = Application.WorksheetFunction.StDev(.Range(.Cells(4, 1), .Cells(CInt(dl), CInt(dc))))
If a = UBound(Counter) Then unit = .Range("E2")
End With
.Close (False)
End With
With WB.Worksheets(1)
.Range("A" & a + 2) = nom
.Range("B" & a + 2) = ave
.Range("C" & a + 2) = deviation
.Range("D" & a + 2) = maximum
.Range("E" & a + 2) = minimum
End With
Next a 'fin condition |
Partager