Hello @Sam White
I know it may sound very intuitive, but have you tried with .EntireRow property?
https://learn.microsoft.com/en-us/office/vba/api/excel.range.entirerow
--If the the reply is helpful, please Upvote and Accept as answer--
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have many excel files as below, where I want to find the duplicate values in a column and highlight the entire row with green color. I have the below code, which is only highlighting the duplicate cells in green color. How can I highlight the entire row which has duplicate values in column B.
![$ex = New-Object -ComObject Excel.application
$ex.visible = $false
$wb = $ex.Workbooks.Open("C:\Temp\Book2.xlsx")
$w1= $wb.Worksheets.item(1)
$w1.activate()
$r= $w1.Range("B2").EntireColumn
$dup = $r.FormatConditions.AddUniqueValues()
$dup.DupeUnique = 1
$dup.Font.ColorIndex =4
$wb.Save()
$wb.Close()][1]
Hello @Sam White
I know it may sound very intuitive, but have you tried with .EntireRow property?
https://learn.microsoft.com/en-us/office/vba/api/excel.range.entirerow
--If the the reply is helpful, please Upvote and Accept as answer--
There is no EntireRow property for $dup, the only properties of $dup are:
PS C:\WINDOWS\system32> $dup
Application :
Creator :
Parent :
Priority :
StopIfTrue :
AppliesTo :
DupeUnique :
Interior :
Borders :
Font :
Type :
NumberFormat :
PTCondition :
ScopeType :
Hello,
@Sam White - I've achieved this like that:
$w1.Rows.Item($a).font.colorindex = 3 #red
$w1.Cells.Item($a,2).font.colorindex = 3 #red
Thank you.
@Anthony Axlen , thanks. Can you please provide the details of the for loop you created.