ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple line (https://www.excelbanter.com/excel-programming/374941-multiple-line.html)

linglc

Multiple line
 
I have a vlookup in my code. Because the code is long I break it into two
lines but I am getting a message that says there is a syntax error. The code
is as follows. Anyone can help me? Thanks.

Selection.FormulaR1C1 =
"=IF((ISERROR(VLOOKUP(C[-4],Table!C[-6]:C[-5],2,0))), _
"""",VLOOKUP(C[-4],Table!C[-6]:C[-5],2,0))"

NickHK

Multiple line
 
You cannot use the line continuation half way through a string. But you can
stop the string and concatenate another :
Dim FormulaStr as string
FormulaStr="=IF((ISERROR(VLOOKUP(C[-4],Table!C[-6]:C[-5],2,0)))," & _
""""",VLOOKUP(C[-4],Table!C[-6]:C[-5],2,0))"
Selection.FormulaR1C1 = FormulaStr

And note the extra " at the end of the first and begining of the first
parts.

NickHK

"linglc" wrote in message
...
I have a vlookup in my code. Because the code is long I break it into two
lines but I am getting a message that says there is a syntax error. The

code
is as follows. Anyone can help me? Thanks.

Selection.FormulaR1C1 =
"=IF((ISERROR(VLOOKUP(C[-4],Table!C[-6]:C[-5],2,0))), _
"""",VLOOKUP(C[-4],Table!C[-6]:C[-5],2,0))"





All times are GMT +1. The time now is 10:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com