I'm reading all lines of another sheet and I paste the value that I want to the active sheet VBA I have a program that read thousands of lines and return the value that I need. The problem is that request take a lot of time probably like 1min just to search and paste the value, even when I'm saving the code it takes a lot of time...

I think it is around this line that the code is slow :

If Sheets("MT950").Cells(line, 1) Like "-}{5:*" Then


Here is my code :

Function mysolde62(mycurrency As String, swift As String) As Double

Dim SearchString As String
Dim LastLine As Long, line As Long, k As Long
Dim mybegin As Long, myend As Long, test As Long, count As Long
Dim sign As String
Dim myvalue As Double

LastLine = Sheets("MT950").Range("A1").End(xlDown).Row

count = 0
myend = 1

For line = 1 To LastLine

If Sheets("MT950").Cells(line, 1) Like "-}{5:*" Then

SearchString = Sheets("MT950").Range("A" &amp; line).Value

mypos = InStr(1, SearchString, swift, 1)
If mypos &lt;&gt; 0 Then
    count = count + 1
End If

End If
Next line

For k = 1 To count

For line = myend To LastLine
If Sheets("MT950").Cells(line, 1) Like "-}{5:*" Then
    SearchString = Sheets("MT950").Range("A" &amp; line).Value

    mypos = InStr(1, SearchString, swift, 1)
    If mypos &lt;&gt; 0 Then

        mybegin = line
        For linebis = mybegin To LastLine
            If Sheets("MT950").Cells(linebis, 1) Like ":62F:*" Then
                SearchString = Sheets("MT950").Range("A" &amp; linebis).Value

                mypos = InStr(1, SearchString, mycurrency, 1)
                If mypos &lt;&gt; 0 Then
                    myend = linebis
                    test = 1
                End If
                Exit For
            End If
        Next linebis

        If test = 1 Then Exit For
    End If
End If
Next line
If test = 1 Then Exit For
Next k


sign = Mid(Sheets("MT950").Cells(myend, 1).Value, 5, 1)
myvalue = Mid(Sheets("MT950").Cells(myend, 1).Value, 15)
If sign = "D" Then
mysolde62 = -myvalue
Else
mysolde62 = myvalue
End If


End Function
Off the bat it appears that you are looping through the entire sheet "MT950" twice.  Doing this once will improve the speed.  Also, the line you said it might be slow around appears twice in your code. 

In your first loop you are running two comparisons, one using the If, Like, Then and then another right after using InStr(1, SearchString, swift, 1).  These can be combined into the following 

For Line = 1 To LastLine
    SearchString = Sheets("MT950").Range("A" &amp; Line).Value
    If InStr(1, SearchString, swift, 1) &lt;&gt; 0 and SearchString Like "-}{5:*" Then Count = Count + 1
Next Line


The second loop appears to be the same as the first only with more stuff happening once you get down inside of it.  I'd recommend merging these two loops, there doesn't seem to be a need to loop through all the rows twice.