'DECLARATION OBJECTS Dim Fichier As String Dim XL As Object Dim MyBook As Excel.Workbook Dim Sheet As Excel.Worksheet Dim first_Line As Integer Dim last_Line As Integer Dim section_Line As Integer Dim side_Line As Integer Dim i As Integer Dim rng As Excel.Range Dim rng1 As Excel.Range 'OPENNING EXCEL APLLICATION Fichier = "C:\Users\Desktop\TEST_LIMITATIONS.xlsx" XL = CreateObject("Excel.Application") 'OPENNING EXCEL FILE CHOSEN BY THE USER MyBook = XL.Workbooks.Open(FileName:=Fichier, ReadOnly:=True) XL.Visible = False Sheet = XL.Worksheets("TEST_LIMITATIONS") 'Detection of the file structure side_Line = 1 last_Line = 1 While (MyBook.ActiveSheet.Cells(side_Line, 1).value Is Nothing) side_Line = side_Line + 1 End While While (MyBook.ActiveSheet.Cells(side_Line + 1, last_Line).value IsNot Nothing) last_Line = last_Line + 1 End While 'Conditions test STP_DES_TYP(AN) = "DIRECTIONAL 5" rng = MyBook.ActiveSheet.Cells(side_Line + 1, 3) rng1 = MyBook.ActiveSheet.Cells(side_Line + 2, 3) If rng.FormulaR1C1 = rng1.FormulaR1C1 Then For i = 0 To last_Line MyBook.ActiveSheet.Cells(i, 1) = "TEST" Next End If section_Line = side_Line + 1 first_Line = side_Line + 3 last_Line = first_Line While (MyBook.ActiveSheet.Cells(last_Line, 1).value IsNot Nothing) last_Line = last_Line + 1 End While last_Line = last_Line - 1