I came across this forum while searching for a problem described here: https://forums.powershell.org/t/getting-filter-in-excel-from-powershell-formula/16648
I used the formula2 field and it does work to enter formulas, although when I check the excel file itself, the field displays a #NAME?
When I click on the field and then once into the edit bar thing and press Enter, it calculates everything correctly so my guess is that it does enter the formula into the field but doesn’t actually go and calculate it? It is kind of annoying and I can’t find a solution nor the reason as why this is happening, so I figured maybe there are some people here that could have a solution
This is the code I use in my script:
#titles for totals
$PatternTotal = "Daily Total",
"Weekly Total",
"Monthly Total",
"Total All"
#formulas for totals
$formulaValue = ("=SUMME(B" + $newRow + ":G" + $newRow + ")"),
("=SUMME(I" + $newRow + ":N" + $newRow + ")"),
("=SUMME(P" + $newRow + ":V" + $newRow + ")"),
("=SUMME(H" + $newRow + ";O" + $newRow + ";W" + $newRow + ")")
#insert totals
foreach ($i in 0..4) {
$col = ($WorkSheet.Columns.Find($PatternTotal[$i]))
$WorkSheet.cells.item($newRow, $col.Column).Formula2 = $formulaValue[$i]
}
EDIT: The original code for row-selection and so on is from here https://pastebin.com/wwjictGS
Thanks a lot already