Have been trying to solve below but no luck so far, seeking for your help :
vba formula return with extra two "@", how to fix the code or remove the "@" in cell R1?
If i want to do a loop and run the vba code from cell R1 to R30, which part of the code should i modify?
Dim PartPoError As Range Dim PART As Range Dim PO As Range Dim lastrow As Long lastrow1 = Sheets("TEMPLATE").Cells(Rows.Count, "A").End(xlUp).Row x = "J" & lastrow1 t = "A" & lastrow1 V = "B" & lastrow1 Set PartPoError = Sheets("rpt_sense").Range("A1", x) Set PART = Sheets("rpt_sense").Range("A1", t) Set PO = Sheets("rpt_sense").Range("B1", V) With Worksheets("rpt_sense") .Range(.Cells(2, 23), .Cells(lastrow1, 23)).ClearContents .Range(.Cells(2, 23), .Cells(lastrow1, 23)).Formula = "=A2&B2" End With lastrow2 = Sheets("template").Cells(Rows.Count, "A").End(xlUp).Row For s = lastrow2 To 16 Step -1 If Sheets("template").Cells(s, 10).Value = "" Then ' Stuck in below formula error....it retunred with extra two "@" in cell formula R1..... Sheets("template").Cells(s, 10) = "=INDEX('rpt_sense'!r:r" & ",MATCH('template'!c8" & "&'template'!B" & s & ",'rpt_sense'!a:a" & "&'rpt_sense'!f:f" & ",0),1)" End If Next s
picture file - index match id and date in yellow from another worksheet
@
in the formula isn't a mistake in itself. Excel adds this to control spill which may well be what you want. The real question is, does the formula work? Another one is whether you want the formula in the cell or its result. I'm always rather reluctant to get VBA to write a formula instead of doing the job itself (maybe using the same function). – Variatus.Formula2
(e.g.rng.Formula2 = "=..."
) ? @talentgreatness – T.M.