I am manipulating an excel sheet with powershell, where some formulas will be added.
That all works, but in excel they are shown as #NAME?
Detail: the formula contains unrecognized text
$FilePath = "C:\Temp 1\Recipes_light.xlsx"
$objexcel = New-Object -ComObject Excel.Application
$objexcel.Visible = $true
$objexcel.DisplayAlerts = $False
$wb = $objexcel.WorkBooks.Open($FilePath)
$ws = $wb.Worksheets.Item(1)
$rows = $ws.UsedRange.Rows.Count
# add column
$range = $ws.Range("E:E").EntireColumn
$range.Insert($xlShiftToRight)
# header
$ws.cells.Item(1,5).Value = "SAP Vertriebstext"
# autofit whole sheet
[void]$ws.cells.entireColumn.Autofit()
# vlookup in excel
$vl = "=SVERWEIS(D2,[GesamtlisteProdukte_Deutschland.xlsx]RMQ!`$C:`$J,8,0)"
$ws.range("E2:E$rows").formula = $vl
If I click in the formular and press "enter" it works. So all cells needed to be touched?
Is there a safe way to add a vlookup formular into excel via powershell?
Thanks in advance