I'm having a problem with a vlookup function. First code shows that VLOOKUP
know what is "TempArg'17"
, but now I want to change it this text to string and write it inside VLOOKUP
, so I created a string temp
.
Dim temp As String
Dim num As Int
num = 17
temp = "TempArg" + "'" + Cstr(num)
Here is the old code that works:
ActiveCell.FormulaR1C1 = _
"=VLOOKUP([@[" & Chr(10) & "Stevilka]],'TempArg''17'!C[-16]:C[-17],2,FALSE)"
And here is the code that I want to change and that doesn't work:
ActiveCell.FormulaR1C1 = _
"=VLOOKUP([@[" & Chr(10) & "Stevilka]],'" & temp & "'!C[-16]:C[-17],2,FALSE)"
This is what I get.
Run-time error '1004':
Application-defined or object-defined error
There's a missing single quote
'
.Change following line:
to
or even better
Also with
Dim num As Int
this won't run.Should be
Dim num As Integer
instead, but I guess this is a typo...