Bold row if duplicate data in column H above

Lizard07

Board Regular
Joined
Jul 20, 2011
Messages
103
Hello - I have a macro code that searches through column H of a file, finds duplicates, and bolds them. The problem is I only want it to bold the column if the duplicate is located above it, not anywhere in the workbook

If the macro could be designed to bold duplicate rows based on a unique identifier in column E then that would also work. In other words, if column H matches and column E matches then bold the duplicate

This is the code I have now


Sub MultipleBillStop()
Dim x As Long, LastRow As Long
'Removes all duplicate route ID's in the hook data sheet
Sheets("Master").Select
LastRow = Range("H65536").End(xlUp).Row
For x = LastRow To 1 Step -1
If Application.WorksheetFunction.CountIf(Range("H1:H" & LastRow), Range("H" & x).Text) > 1 Then
If Application.WorksheetFunction.CountIf(Range("H" & x + 1 & ":H" & LastRow + 1), Range("H" & x).Text) > 0 Then
Range("H" & x).EntireRow.Font.Bold = True

End If
End If
Next x
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try

Code:
Sub test()
Dim LR As Long, i As Long
LR = Range("E" & Rows.Count).End(xlUp).Row
For i = 2 To LR
    If Range("E" & i).Value = Range("E" & i - 1).Value And Range("H" & i).Value = Range("H" & i - 1).Value Then Rows(i).Font.Bold = True
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top