# Update Existing Excel Workbooks

Replace values, edit rows, append table data, and make targeted workbook changes without rebuilding every sheet.

Existing-workbook automation should express the smallest useful mutation. That makes the script easier to review and reduces the chance of replacing formulas, styles, or unrelated worksheets.

## Replace text or edit rows

`Update-OfficeExcelText` supports sheet and range boundaries, literal or regex matching, case sensitivity, and `-WhatIf`. `Edit-OfficeExcelRow` exposes a row object with header-aware access for conditional changes.

```powershell
Update-OfficeExcelText -Path '.\Readiness.xlsx' -Sheet Readiness `
    -Pattern Draft -Replacement Ready -SimpleMatch

Edit-OfficeExcelRow -Path '.\Readiness.xlsx' -Sheet Readiness -ScriptBlock {
    param($row)
    if ($row.CellByHeader('Service').Value -eq 'Messaging') {
        $row.Set('Owner', 'Productivity')
    }
}
```

## Append without rebuilding

Open the workbook with `Open-OfficeExcel`, pipe it to `Add-OfficeExcelTableRow`, then save with `Save-OfficeExcel` and close with `Close-OfficeExcel`. Other targeted commands update cells, formulas, styles, links, print settings, visibility, active sheet, filters, comments, validation, and workbook metadata.

The [update-existing recipe](https://github.com/EvotecIT/OfficeIMO/blob/3b680b1b6fb15a268ff5525a4ca6cdd70b2f6613/PowerShell/PSWriteOffice/Examples/Excel/Recipe-Excel-UpdateExisting.ps1) combines workbook-wide text replacement with a header-aware row edit.

<!-- PowerForge markdown source sha256:E6A1283DD90DEB2AC0CF39C110CACDCCA07266F3153C25CCFCE7CC820E93E0B1; title=True -->

<!-- PowerForge markdown artifact sha256:4398EA794E7A5898432719F32B41D65D5AA77B239B565269733C0375F28B4226 -->
