Need VBA Coding

Smith William
Smith William used Ask the Experts™
on
Hi Experts,

Please help me with code. I have attached excel file. In that Column D has resource name, there if there name is repeating for more than 2 times shows some pop up or highlight the repeated.
Book1.xlsx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
There is no attachment, also please share more detail in what you want to accomplish, or some example of your target result
Senior Developer
Commented:
E.g. in a standard module:

Option Explicit

Public Sub Run()

  MarkContinousValues ActiveSheet.Columns("D")

End Sub

Public Sub MarkContinousValues(ARange As Excel.Range)

  Const BAILOUT As Long = 16

  Dim Cell As Excel.Range
  
  Dim BailoutCount As Long
  Dim PreviousValue As Variant
  Dim RepetionCount As Long
  
  For Each Cell In ARange.Cells
    If Cell.Value = vbEmpty Then
      BailoutCount = BailoutCount + 1
      If BailoutCount >= BAILOUT Then
        Exit For
      End If
    End If
    
    If PreviousValue = Cell.Value Then
      RepetionCount = RepetionCount + 1
      If RepetionCount >= 2 Then
        Cell.Font.Color = RGB(255, 0, 0)
      End If
    Else
      RepetionCount = 0
    End If
    
    PreviousValue = Cell.Value
  Next Cell

End Sub

Open in new window

Author

Commented:
Thank you Ste5an

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial