Reputation: 904
When I search through an Excel file from powershell, I want to get the row and column of the cell with a specific content.
To do so, I have the following code:
[threading.thread]::CurrentThread.CurrentCulture = 'en-US'
$e = new-object -com excel.application
$book = $e.Workbooks.Open("C:\tmp\deeg.xlsx")
$sheet = $book.WorkSheets.item(1)
$Cell = $sheet.range("A1:Z8").find("deeg")
Write-Host "Line: " $Cell.rows
$a = read-host 'Press any key'
The method 'Rows' does not seem to exist... How can I the the row number and column number?
Upvotes: 0
Views: 9659
Reputation: 1598
Every cell-object has a address()-Method
$cell.address($false,$false)
gives back the cell-address eg. A5. The switches ($false,$false) calls an relative cell-address (so, not $A$5).
Upvotes: 1