In support of this Thread answer
http://www.eileenslounge.com/viewtop...=34247#p265646
Code:Option Explicit Sub DDAllEarlier_Marz172020() ' http://www.eileenslounge.com/viewtopic.php?f=55&t=34247#p265646 Dim WsDDD As Worksheet: Set WsDDD = Worksheets("DDAllEarlier_Marz17") Dim RngDD As Range, rngDB As Range ' =ANZAHL2(B2:B550) 255 =ANZAHL2(D2:D550) 366 Set RngDD = WsDDD.Range("B2:B550"): Set rngDB = WsDDD.Range("D2:D550") ' take each cell in column B range and find it in column D, but find next if the text is already coloured Dim Rng As Range For Each Rng In RngDD '----------------------| If Rng <> "" Then Dim ClrIdx As Long: Randomize: Let ClrIdx = (Int(Rnd * 54)) + 3 Dim FndRng As Range Set FndRng = rngDB.Find(what:=Rng.Value, After:=rngDB.Cells.Item(1), LookAt:=xlPart, searchorder:=xlNext, MatchCase:=False) ' If Not FndRng Is Nothing Then ' we have a match that may or may not have already been found. Do While Not FndRng Is Nothing ' === If FndRng.Font.Color = 0 Then ' case "virgin black" text FndRng.Select Let FndRng.Font.ColorIndex = ClrIdx Application.Wait (Now + TimeValue("00:00:01")) Rng.Select Let Rng.Font.ColorIndex = ClrIdx Application.Wait (Now + TimeValue("00:00:01")) Set FndRng = Nothing ' This will force the Loop to end after a succesful match Else ' The cell text is already colored, so try again Set FndRng = WsDDD.Range("D" & FndRng.Row + 1 & ":D550").Find(what:=Rng.Value, After:=WsDDD.Range("D550"), LookIn:=xlValues, LookAt:=xlPart, searchorder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) ' https://stackoverflow.com/questions/49094391/excel-vba-range-findnext-v-range-find-what-have-i-missed/49181464#49181464 End If Loop ' looping for next match ====== Else ' no cell value match End If Else ' case rng has not text in it End If Next Rng ' Each Rng In RngDD ---------------| End Sub




Reply With Quote
Bookmarks