Thread: Multiple line
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default 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))"