Hi there!
I want to enter the VLOOKUP function in Excel cell with a macro.
I want to always have the same selections as the table size.
I did this:
"Sub Fkeres_Munkafelvevo_AMCTR8()
'
' Fkeres_Munkafelvevo_AMCTR8 Makró
'
'
Dim sorszam As String
Dim osszefuz As String
Dim kijeloltresz As String
Dim fkeres As String
Range("A2").Select
Selection.End(xlDown).Select
sorszam = ActiveCell.Row
osszefuz = "S" & sorszam
kijeloltresz = "B2:" & osszefuz
Sheets("Munka1").Select
fkeres = "=VLOOKUP(RC[-18],AMCTR9! " & kijeloltresz & ",18,FALSE)"
Range("W2").Select
ActiveCell.FormulaR1C1 = fkeres
Selection.Copy
osszefuz = "W" & sorszam
kijeloltresz = "W2:" & osszefuz
Range(kijeloltresz).Select
ActiveSheet.Paste
End Sub"
In the macro, the contents of the VLOOKUP are what I want to see: "= VLOOKUP (E2; AMCTR9! B2: S555; 18; FALSE) "
However, after you run the macro, it appears in the cell: "= VLOOKUP (E2; AMCTR9!' B2 ': 'S 555 '; 18; FALSE) "
Almost good. Why are apostrophes included?
Thanks for your help.
Regards:
Józsi