Hi, everyone! I hope you have a good day.

I have this problem that I have to put a formula in a button in VBA, and I've tried all of the ways here https://www.automateexcel.com/vba/formula-formular1c1 but nothing works and always give me the error from Macro.

My original code is:

Range("C" & (maxMarker + 4)).Select
    Selection.FormulaR1C1 = _
        "=IF(ISBLANK(R[-20]C),"""",VLOOKUP(R[-20]C,ASetup,10,0))"
maxMarker is a variable that could change, hence why I put it as "C" & (maxMarker + 4).

I want to get the value from cell C2 and I got that code from Record Macro, but since [-20] means 20 from the current active cell, and so whenever the values change, the generated formula from the button changes and it is no longer from C2.

The formula I want should be =IF(ISBLANK(C2),"",VLOOKUP(C2,ASetup,10,0)) but every time I put it there it's always giving me errors. I've tried the Range("C" & (maxMarker + 4)).Formula, the R1C1 one and it's always giving me errors. Is there a another way to put the =IF(ISBLANK(C2),"",VLOOKUP(C2,ASetup,10,0)) there?

I'd really, really appreciate it if anyone would kindly help me on this. Thank you so much, stay safe always!