It's a little long:
You need to add the "
inside your formula, I like to use the Chr(34)
to add it.
So first, your aa
is a varaible that changes every time you advance i
in the loop, so inside the formula you need to break the constant part and add " & aa & "
every time you use it.
But, you need to add the "
to aa
, that's why I modifed your aa
line to:
aa = Chr(34) & ThisWorkbook.Sheets(3).Cells(i, "A").Text & Chr(34)
Second, I added a String
variable named Myfor
, and set the value to it Myfor = Chr(34) & "for " & Chr(34)
, just to try to "shorten" the formula a little.
Code
Dim aa As String
Dim Myfor As String
Myfor = Chr(34) & "for " & Chr(34)
For i = 2 To lastRow
aa = Chr(34) & ThisWorkbook.Sheets(3).Cells(i, "A").Text & Chr(34)
ThisWorkbook.Sheets(3).Cells(i, "E").Formula = "=MID(" & aa & ",FIND(" & Myfor & "," & aa & ")+4, FIND("" ""," & aa & ",FIND(" & Myfor & "," & aa & ")+4)-(FIND(" & Myfor & "," & aa & ")+4))"
Next i