目前,我使用以下代码使用vlookup为表生成一些新列。我怎么能命名新列以及它们的当前名称是第1列,第2列,第3列等。非常感谢!
Columns("A").Delete
Dim lastrow As Long
lastrow = Range("A2").End(xlDown).Row
Range("AE2:AE" & lastrow).FormulaR1C1 = "=IF(RC[+1]=""PAYING"", VLOOKUP(RC[-30],'Sheet2'!R1C1:R20000C8,8,0),""PENDING"")"
Range("AF2:AF" & lastrow).FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-31],'Sheet2'!R1C1:R20000C8,2,0), ""PENDING"")"
Range("AG2:AG" & lastrow).FormulaR1C1 = "=(LEN(RC[-31])-LEN(SUBSTITUTE(RC[-31], "";"", """"))+1)*1200"
Range("AH2:AH" & lastrow).FormulaR1C1 = "=VLOOKUP(RC[-33],'Sheet3'!R2C2:R220C4,2,0)"
Range("AI2:AI" & lastrow).FormulaR1C1 = "=VLOOKUP(RC[-34],'Sheet3'!R2C2:R220C4,3,0)"
Columns("X:AI").EntireColumn.AutoFit
答案 0 :(得分:0)
命名范围非常简单:
Range("AE2:AE" & lastrow).Name = "NamedRange1"
Range("AF2:AF" & lastrow).Name = "NamedRange2"
Range("AG2:AG" & lastrow).Name = "NamedRange3"
Range("AH2:AH" & lastrow).Name = "NamedRange4"
Range("AI2:AI" & lastrow).Name = "NamedRange5"