where do i go from here?

Rivie

New Member
Joined
Jul 29, 2020
Messages
11
Office Version
  1. 2016
Platform
  1. Windows
so far this is the code i have:
Private Sub Worksheet_Change_C(ByVal Target As Range)
If Target.Row = 1 Then Exit Sub
On Error GoTo ErrHandler
Application.ScreenUpdating = False

Dim myDataRng As Range
Dim cell As Range
Set myDataRng = Range("B1:B" & Cells(Rows.Count, "B").End(xlUp).Row)

For Each cell In myDataRng
cell.Offset(0, 0).Font.Color = vbBlack

If Application.Evaluate("COUNTIF(" & myDataRng.Address & "," & cell.Address & ")") > 1 Then
cell.Offset(0, 0).Font.Color = vbRed
End If
Next cell

Set myDataRng = Nothing
ErrHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

i need the code to check column F to see if a corresponding cell is true or false or i need it to check the next duplicate range to see if the cells exactly match. basically if the b column if a duplicate i need it to see if 2 cells to the right has a date input and if it does then the duplicate is not a true duplicate to not turn it red. i'm not even sure if this is possible
 
See if the below is doing what you want..

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim myDataRng As Range, myCell As Range
    If Target.Row = 1 Or Target.CountLarge > 1 Then Exit Sub

    Set myDataRng = Range("B2:B" & Cells(Rows.Count, "B").End(xlUp).Row)
    Application.ScreenUpdating = False

    If Not Intersect(Target, myDataRng) Is Nothing Then
        Application.EnableEvents = False

        myDataRng.Font.Color = vbBlack

        For Each myCell In myDataRng
            If Application.Evaluate("COUNTIF(" & myDataRng.Address & "," & myCell.Address & ")") > 1 And _
            myCell.Offset(, 2) = "" Then myCell.Font.Color = vbRed
        Next myCell

        Set myDataRng = Nothing

        Application.EnableEvents = True
    End If

    Application.ScreenUpdating = True
End Sub
that seems to be doing exactly what i needed it to do. Thanks so much!! ??
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,214,622
Messages
6,120,585
Members
448,972
Latest member
Shantanu2024

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