Before I get started, I have researched for solutions and seem unable to produce similar results. Notably, I attempted the solutions in How can I insert variable into formula in VBA And Using string variables within a formula in VBA
So, I have set a variable to refer to a named range in another workbook, for use in a vlookup. Even after trying double quotes or none at all it refuses to work, I also tried making it based off RC cell format instead of my Range("N2"). I know there are other ways to process the vlookup but I would like to solve this.
Dim cwb as workbook ' (this is a different workbook than the current one)
Dim crng as range
Dim frmcount as long
Dim checkcsht as string, cwbname as string
Set crng = csht.Range("D:P")
checkcsht = "crng"
cwb.Names.Add Name:=checkcsht, RefersTo:=crng
cwbname = cwb.Name
cwbname = "'[" & Left(cwb.Name, Len(cwb.Name) - 5) & "]'!crng"
Debug.Print cwbname
'gather raildata from cont-report
frmcount = Application.CountA(frmsht.Range("A:A"))
With frmsht.Range("N2")
.FormulaR1C1 = "=IF(ISNA(VLOOKUP(RC[-11],""" & cwbname & """, 12, False)), """", (VLOOKUP(RC[-11],""" & cwbname & """, 12, False)))"
.AutoFill Destination:=.Parent.Range("N2:N" & frmcount), Type:=xlFillDefault
Calculate
.EntireColumn.Copy
.EntireColumn.PasteSpecial xlPasteValues
End With
Everything was DIM'd and set at some point to the proper value. Any ideas on what I am missing?