我想设置数组公式:
=VLOOKUP(MID([@[Source Sheet]];FIND(".";[@[Source Sheet]];1)+1;15);Tbl_PN[[Hostname]:[Allocated on:]];COLUMN(Tbl_PN[[#Headers];[Allocated on:]])-2;0)
在表格中,但我收到错误:
运行时错误1004无法设置的FormulaArray属性 范围类
Tbl_PN在我试图设置数组表的表的另一张表上。 BTW如果我将公式手册复制到工作表上,那么它工作正常,如果我将“.formula”行上的公式更改为“= -3”,那么代码运行正常
With Wb.Sheets(Sht1)
lastrow = .Cells(.Rows.Count, StartCell.Column).End(xlUp).Row
lastcolumn = .Cells(StartCell.Row, .Columns.Count).End(xlToLeft).Column
Set TblRange = Range(StartCell, Cells(lastrow, lastcolumn)) ' set range to create new table
Set ObjTable = .ListObjects.Add(xlSrcRange, TblRange, , xlYes) ' create new table
ObjTable.Name = "tbl_" + Sht1 ' set table name
ObjTable.TableStyle = "TableStyleLight9" ' set table style"
ObjTable.ListColumns.Add.Name = "Frame" ' add column to table
ObjTable.ListColumns("Frame").Range.NumberFormat = "General" ' set format new column to general (other are text)
ObjTable.ListColumns("Frame").DataBodyRange(1).FormulaArray = "=VLOOKUP(MID([@[Source Sheet]];FIND(""."";[@[Source Sheet]];1)+1;15);Tbl_PN[[Hostname]:[Allocated on:]];COLUMN(Tbl_PN[[#Headers];[Allocated on:]])-2;0)"
End With