MoriteUK
MoriteUK

Reputation: 27

Putting formula in cell with Powershell

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?

Upvotes: 0

Views: 6154

Answers (1)

Baldrick
Baldrick

Reputation: 11840

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)"

Upvotes: 1

Related Questions