0

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) & "Številka]],'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) & "Številka]],temp'!C[-16]:C[-17],2,FALSE)"

Thanks in advance.

1
  • Whare the two column in the lookup range? Commented Mar 14, 2018 at 15:32

1 Answer 1

2

Try this

"=VLOOKUP([@[" & Chr(10) & "Številka]],'" & temp & "'!C[-16]:C[-17],2,FALSE)"

Sign up to request clarification or add additional context in comments.

2 Comments

might need a ' on the left side of temp.
Thanks, but it says "Syntax Error" :-/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.