Putting formula in cell with Powershell

一笑奈何 提交于 2019-12-11 17:45:04

问题


I have an issue putting a formula in an excel cell. The formula contains a variable.

$batchname = Batch15c

$ws.Cells.Item(2,5).value() = "=VLOOKUP(RC[-1],[$batchname]Sheet1!$A$1:$D$300,2,FALSE)

I get the following error:-Exception setting "Value": "Exception from HRESULT: 0x800A03EC"

anybody got any ideas?


回答1:


I believe should be setting the Formula property instead of Value.

Try:

 $ws.Cells.Item(2,5).Formula = "=VLOOKUP(RC[-1],[$batchname]Sheet1!$A$1:$D$300,2,FALSE)"


来源:https://stackoverflow.com/questions/22859584/putting-formula-in-cell-with-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!