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
| Public Function Ligne(File As String) As Long
Dim AppExcel As Excel.Application
Dim wbFile As Excel.Workbook
Dim i As Long
'Initialisation
Ligne = -1
i = 1
'Ouverture d'excel
Set AppExcel = CreateObject("Excel.Application")
If Not AppExcel Is Nothing Then
'Ouverture du classeur
Set wbFile = AppExcel.Workbooks.Open(File, False, True)
If Not wbFile Is Nothing Then
i = 1
Do While Cells(i, 1).Value <> "TOTAL" Or Cells(i, 1).Value <> "Total"
i = i + 1
Loop
Ligne = i
wbFile.Close
Set wbFile = Nothing
End If
AppExcel.Application.Quit
Set AppExcel = Nothing
End If
End Function |
Partager