Here is my sample code:
$wb = $excel.ActiveWorkbook
ForEach ($ws in $wb.Worksheets) {
"Working on {0}" -f $ws.Name
forEach ($row in $ws.Rows) {
forEach($cell in $row.Cells) {
if ($cell.HasFormula) {
$formula = $cell.Formula
if ( ($formula -match "foobar") {
"{0} R{1}C{2}:{3}" -f $ws.Name, $row.Row, $cell.Column, $formula
}
}
}
}
}
The performance is not good because the spreadsheet is too big. I want to
1) can I retrieve all formula in one function call? Does excel support it?
2) In the case a formula is assigned to an array of cells, how can I extract the formula?
Maybe this link can give you some hints to get a list of formulas in a sheet.
note: type xlCell Constants