Dim lastrow, prodflow As String
lastrow = Range("C65536").End(xlUp).Row 'Determine last row where data ends
Range("G2:G" & lastrow).Formula = "=VLOOKUP(LEFT(RC[-1],FIND(""-"",RC[-1],1)+4),'[Process Flows.xlsx]TABLE_X'!R1C1:R999C70,14,FALSE)"
但是当我尝试用变量prodflow替换TABLE_X时,我的公式语句中出现运行时错误:
Dim lastrow, prodflow As String
lastrow = Range("C65536").End(xlUp).Row 'Determine last row where data ends
prodflow = Cells(2, 2) 'Read value in cell B2 and store as string
Range("G2:G" & lastrow).Formula = "=VLOOKUP(LEFT(RC[-1],FIND(""-"",RC[-1],1)+4),'[Process Flows.xlsx]" & prodflow & "'!R1C1:R999C70,14,FALSE)"
我已经搜索了这个问题,所有类似问题的答案都指出我所做的是正确的。还有什么我错过了吗?谢谢!
答案 0 :(得分:0)
尝试构建公式字符串,然后将其分配给范围公式:
dim f =“= a + b”
范围。 FORMULA = F
从immidiate窗口获取f结果并在excel中检查...如果它工作,它应该在你的代码中工作。