Hi,
There is really nothing wrong with the first formula, although I have
simplified them slightly.
To correct the second formula use:
With target
.Offset(0, -1) = "=row()-2"
.Offset(0, 1) = "=Vlookup(B" & .Row & ",Sheet2!$A$1:$B$7,2,False)"
End With
In general quotes are like parentheses - there should be an equal number.
In this case you want to make the .Row argument a vba variable so it must be
outside the quoted text otherwise it is taken literally. This means that you
will need an " & vbaVariable & " type of layout. You got half of it.
As for single quotes, these often appear around path references, especially
those that contain names with spaces. The easiest way to handle them is to
record the code. In fact that is the easiest way to start entering your
formulas in code - record them, and then modify them.
The idea of having a equal number of quotes (single or double) is a general
rule which may not always hold. For example if your formula is looking for a
' in a string then the single quote might appear once.