Option Base 1
Sub again()

Dim tableau()

Dim NumRay As Integer

Dim j As Integer

Close #1
Sheet1.Cells.Clear

chemin = "C:\Users\212426882\Documents\TrackLight Integrator\Pour Optis\Output\Default\Interactive Simulation.txt"

Open chemin For Input As #1

NumImpact = 0
NumRay = 0

ReDim tableau(2, 1)

Do Until EOF(1)
Line Input #1, TextLine

If InStr(TextLine, Ray) > 0 Then
    If NumRay = 0 Then
	
        NumRay = Val(TextLine)

        ReDim tableau (2 To 2, 2 To NumRay)         
        
	tableau(1, 1) = NumRay
        
        NumImpact = 0
        
        Else
	
	ReDim Preserve tableau (2 to 2, NumRay to NumRay + 1)

        tableau(2, NumRay) = NumImpact
       
        NumRay = Val(TextLine)
	
        tableau(1, NumRay) = NumRay
        
        NumImpact = 0
        
    End If       
        
    ElseIf InStr(TextLine, Impact) > 0 Then
    
    NumImpact = NumImpact + 1
    
       
End If

Loop

For j = 1 To UBound(tableau, 2)
ActiveSheet.Range("A" & j) = tableau(1, j)
ActiveSheet.Range("B" & j) = tableau(2, j)
Next j

Close #1

End Sub